Skip to content

Instantly share code, notes, and snippets.

@MasoudFallahpour
Last active June 14, 2022 19:18
Show Gist options
  • Save MasoudFallahpour/cf8af7c1d70feb62dd560036e7508cc4 to your computer and use it in GitHub Desktop.
Save MasoudFallahpour/cf8af7c1d70feb62dd560036e7508cc4 to your computer and use it in GitHub Desktop.
fun main() = runBlocking {
val job = launch(CoroutineName("parent")) {
launch {
delay(2000)
println("coroutine1: I'm done")
}
launch {
delay(3000)
println("coroutine2: I'm done")
}
}
println("Cancelling the parent coroutine...")
job.cancelAndJoin()
println("Parent coroutine cancelled")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment