-
-
Save PatilShreyas/1fe82c179f3f5e46dccdb0f97d80fa4f to your computer and use it in GitHub Desktop.
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
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