Created
July 7, 2021 11:45
-
-
Save adesamp/f16431112bb57517f0b63ce6af6230a4 to your computer and use it in GitHub Desktop.
asynctest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Test | |
fun `Await Test`() { | |
runBlocking { | |
val deferred: Deferred<String> = async { return@async Thread.currentThread().name } | |
println(deferred.await()) | |
} | |
} | |
@Test | |
fun `AwaitAll Test`() { | |
runBlocking { | |
val deferred1: Deferred<Int> = async { 1 } | |
val deferred2: Deferred<Int> = async { 2 } | |
val deferred3: Deferred<Int> = async { 3 } | |
println(awaitAll(deferred1, deferred2, deferred3).sum()) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment