VP
Size: a a a
VP
I
@Synchronized
зачем?I
VP
I
I
I
I
I
VP
VP
I
val handler = CoroutineExceptionHandler { _, exception ->
println("CoroutineExceptionHandler got $exception")
}
val scope = CoroutineScope(SupervisorJob())
suspend fun criticalSectionSuspending() {
println("Starting!")
val scope2 = CoroutineScope(coroutineContext)
val someJob = scope2.launch {
delay(200)
println("Delay!")
throw Exception("Delay Exception")
}
println("Ending!")
}
fun main() {
scope.launch(handler) {criticalSectionSuspending()}
Thread.sleep(500)
}
I
VP
val handler = CoroutineExceptionHandler { _, exception ->
println("CoroutineExceptionHandler got $exception")
}
val scope = CoroutineScope(SupervisorJob())
suspend fun criticalSectionSuspending() {
println("Starting!")
val scope2 = CoroutineScope(coroutineContext)
val someJob = scope2.launch {
delay(200)
println("Delay!")
throw Exception("Delay Exception")
}
println("Ending!")
}
fun main() {
scope.launch(handler) {criticalSectionSuspending()}
Thread.sleep(500)
}
I
VP
try { }
В общем, очень плохой подход, не надо так. Поддерживаемость такого кода будет на дне.I
VP
suspend fun criticalSectionSuspending() = coroutineScope {
println("Starting!")
val someJob = launch {
delay(200)
println("Delay!")
throw Exception("Delay Exception")
}
println("Ending!")
}
VP
try { }
?I