Skip to content

Instantly share code, notes, and snippets.

@MasoudFallahpour
Created June 14, 2022 19:24
Show Gist options
  • Save MasoudFallahpour/067cc9d85b89046d00a213e227fc2fe0 to your computer and use it in GitHub Desktop.
Save MasoudFallahpour/067cc9d85b89046d00a213e227fc2fe0 to your computer and use it in GitHub Desktop.
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