oday
09/16/2022, 5:29 PMprivate fun startCoroutines() {
GlobalScope.launch(Dispatchers.Main) {
withTimeout(1000L) {
println("This is executed before the first delay")
stallForTime()
println("This is executed after the first delay")
}
printAfterSomething("the timeout")
}
println("This is executed immediately")
}
suspend fun stallForTime() {
withContext(Dispatchers.Default) {
delay(2000L)
}
}
after the child job inside withTimeout
does not finish in time (because stallForTime made it take too long (2 seconds))
why does the printAfterSomething
not get calledoday
09/16/2022, 5:29 PMprintAfterSomething
print statement?oday
09/16/2022, 5:30 PMjw
09/16/2022, 5:44 PModay
09/16/2022, 6:02 PModay
09/16/2022, 6:03 PModay
09/16/2022, 6:07 PModay
09/17/2022, 1:04 PMjw
09/17/2022, 1:20 PM