Skip to content

Instantly share code, notes, and snippets.

@PatilShreyas

PatilShreyas/Async.kt Secret

Created Dec 30, 2020
Embed
What would you like to do?
fun main() = runBlocking {
val one = async { taskOne() }
val two = async { taskTwo() }
val result = one.await() + two.await() // 10 + 20
}
suspend fun taskOne(): Int {
delay(100L)
return 10
}
suspend fun taskTwo(): Int {
delay(400L)
return 20
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment