Skip to content

Instantly share code, notes, and snippets.

@adesamp
Created July 7, 2021 11:45
Show Gist options
  • Save adesamp/f16431112bb57517f0b63ce6af6230a4 to your computer and use it in GitHub Desktop.
Save adesamp/f16431112bb57517f0b63ce6af6230a4 to your computer and use it in GitHub Desktop.
asynctest.kt
@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