Skip to content

Instantly share code, notes, and snippets.

@MasoudFallahpour
Last active June 27, 2022 08:34
Show Gist options
  • Save MasoudFallahpour/61ee97be71595dabcc77f817a1639047 to your computer and use it in GitHub Desktop.
Save MasoudFallahpour/61ee97be71595dabcc77f817a1639047 to your computer and use it in GitHub Desktop.
import kotlinx.coroutines.*
fun main() = runBlocking {
launch(CoroutineName("parent")) {
launch {
println("coroutine1 started")
delay(500)
throw RuntimeException()
}
launch {
try {
println("coroutine2 started")
delay(1000)
println("coroutine2 ended")
} catch (ex: CancellationException) {
println("coroutine2 canceled")
}
}
delay(2000)
println("parent coroutine ended")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment