Halina
finally
withContext(NonCancellable)
Endre Deak
Coroutine finished
import kotlinx.coroutines.* suspend fun main(): Unit = coroutineScope { val job = Job() launch(job) { try { println("Coroutine started") delay(200) println("Coroutine finished") } finally { println("Finally") withContext(NonCancellable) { launch { println("Children executed") } delay(1000L) println("Cleanup done") } } } delay(100) job.cancelAndJoin() println("Done") } // Coroutine started // (0.1 sec) // Finally // Children executed // (1 sec) // Cleanup done // Done
Mervyn McCreight
delay(200)
println("Coroutine finished")
cancelAndJoin
A modern programming language that makes developers happier.