Created
June 14, 2022 19:24
-
-
Save MasoudFallahpour/067cc9d85b89046d00a213e227fc2fe0 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 job = launch(CoroutineName("parent")) { | |
println("Launching two coroutines...") | |
val child1Job = launch { | |
println("coroutine1: I'm started") | |
delay(2000) | |
println("coroutine1: I'm done") | |
} | |
launch { | |
println("coroutine2: I'm started") | |
delay(3000) | |
println("coroutine2: I'm done") | |
} | |
delay(1000) | |
child1Job.cancel() | |
} | |
job.join() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment