Skip to content

Instantly share code, notes, and snippets.

@PatilShreyas
Created December 30, 2020 08:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PatilShreyas/1fe82c179f3f5e46dccdb0f97d80fa4f to your computer and use it in GitHub Desktop.
Save PatilShreyas/1fe82c179f3f5e46dccdb0f97d80fa4f to your computer and use it in GitHub Desktop.
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