rook
04/13/2021, 4:19 PMinvokeOnCompletion. Given the following
launch(Dispatchers.Default) {
val theJob = async(<http://Dispatchers.IO|Dispatchers.IO>) {}
// do some work
theJob.invokeOnCompletion { println() }
}
If do some work takes longer than theJob to complete, the handler block runs on Dispatchers.Default, whereas if theJob takes longer than do some work, the handler block runs on <http://Dispatchers.IO|Dispatchers.IO>.diesieben07
04/13/2021, 4:21 PMNote: Implementation of CompletionHandler must be fast, non-blocking, and thread-safe. This handler can be invoked concurrently with the surrounding code. There is no guarantee on the execution context in which the handler is invoked.
rook
04/13/2021, 4:22 PM