Coroutines That Call Functions With Blocking Code
I’m trying to confirm if my understanding of coroutines is correct.
Given that: methodThatContainsBlockingCode(i) calls some sort of blocking code, be it jdbc, REST call, etc…
Then 10 lightweight threads will be created and block execution till the last one completes
// methodThatContainsBlockingCode(i) is a 'mocked' function that calls Thread.sleep(3_000)
suspend fun process() : Unit {
withContext(
Dispatchers.IO) {
for (i in 1 .. 10) {
async() {...