Last active
June 27, 2022 08:34
-
-
Save MasoudFallahpour/61ee97be71595dabcc77f817a1639047 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
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