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

前端 未结 8 2150
闹比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 17:52

    Alongside the other great answers, for the people familiar with Rx and getting into coroutines, async returns a Deferred which is akin to Single while launch returns a Job that is more akin to Completable. You can .await() to block and get the value of the first one, and .join() to block until the Job is completed.

提交回复
热议问题