AN
Size: a a a
AN
AM
AN
AM
AN
I
AM
AM
I
AM
AM
I
I
AM
I
val handler = CoroutineExceptionHandler { _, exception ->
println("CoroutineExceptionHandler got $exception")
}
val scope = CoroutineScope(SupervisorJob())
val scope2 = CoroutineScope(Job())
@Synchronized
suspend fun criticalSectionSuspending() {
println("Starting!")
val someJob = scope2.launch {
delay(20)
println("Delay!")
throw Exception("Delay Exception")
}
println("Ending!")
}
fun main() {
scope.launch(handler) {criticalSectionSuspending()}
}
AL
scope.launch { try { criticalSectionSuspending() } catch (e: Throwable) { } }
I
CoroutineExceptionHandler
I
AL
scope2
AL
println("Starting!")
и println("Ending!")
отработают почти мгновенно