elizarov
04/11/2017, 8:20 PMThread.sleep(1000)
which blocks a thread for 1 second, then no amount of wrapping it into async
will let you handle 100k of such operations simultaneously. However, with delay(1000)
(non-blocking, but suspending) it is a nobrainer. You are welcome to perform an experiment from here yourself to verify it: https://github.com/Kotlin/kotlinx.coroutines/blob/master/coroutines-guide.md#coroutines-are-light-weight I really recommend trying both the async version and the one where you replace launch(CommonPool) {...}
with thread {...}
and delay
with Thread.sleep
.