Created
June 7, 2022 19:57
-
-
Save jaozinfs/94b509e27b1b79a11a4b3523b68de722 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 handler = CoroutineExceptionHandler { _, exception -> | |
println("CoroutineExceptionHandler hot $exception") | |
} | |
val job = launch(handler) { | |
supervisorScope { | |
launch { | |
downloadImage() | |
println("finish download 1") | |
} | |
launch { | |
downloadSounds() | |
println("finish download 2") | |
} | |
} | |
println("finish downloads") | |
} | |
job.join() | |
println("Finish Job") | |
} | |
suspend fun downloadImage(){ | |
(1..2).onEach { | |
delay(300) | |
println("image $it") | |
} | |
} | |
suspend fun downloadSounds() { | |
(1..2).onEach { | |
delay(300) | |
throw Exception("Error on get sound $it") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment