Kotlin Coroutines Wait Multiple / Await All Deferred to Complete

July 22, 2019
launch(Dispatchers.Default) {
    val d1 = async {
        delay(1000)
        "result1"
    }

    val d2 = async {
        delay(5000)
        "result2"
    }

    val (r1, r2) = listOf(d1, d2).awaitAll()
    Timber.d("r1=$r1, r2=$r2")
}
This work is licensed under a
Creative Commons Attribution-NonCommercial 4.0 International License.