What is the difference between launch/join and async/await in Kotlin coroutines

前端 未结 8 2141
闹比i
闹比i 2020-11-30 17:17

In the kotlinx.coroutines library you can start new coroutine using either launch (with join) or async (with await<

8条回答
  •  情书的邮戳
    2020-11-30 18:06

    Async vs Launch Async vs Launch Diff Image

    launch / async no result

    • Use when don't need result,
    • Don't block the code where is called,
    • Run in parallel

    async for result

    • When you need to wait the result and can run in parallel for efficiency
    • Block the code where is called
    • run in parallel

提交回复
热议问题