Rainer Schlonvoigt
01/04/2021, 11:06 AMval dispatcher = Executors.newSingleThreadExecutor().asCoroutineDispatcher()
val scope = CoroutineScope(dispatcher)
for (i in 1..5) {
scope.launch {
println(i)
}
}
Rainer Schlonvoigt
01/04/2021, 11:06 AMRainer Schlonvoigt
01/04/2021, 11:07 AMtseisel
01/04/2021, 12:44 PMCoroutineDispatcher
is based on a Java single thread executor, coroutines are executed sequentially, in the order of submission.
Note that this is not guaranteed for all CoroutineDispatcher
implementations.Rainer Schlonvoigt
01/04/2021, 1:16 PMRainer Schlonvoigt
01/04/2021, 1:16 PMAdam Powell
01/04/2021, 6:47 PMgildor
01/05/2021, 12:01 AMbdawg.io
01/05/2021, 5:29 AM