Assuming doAsync runs the inner lambdas concurrently, would runBlocking the outer scope force these to run synchronously ?
w
wasyl
04/02/2021, 4:45 PM
No, runBlocking doesn’t mean thing inside are blocking one another, it’s just a coroutine builder that only returns after the coroutines inside have finished
wasyl
04/02/2021, 4:46 PM
But you still need to have enough threads available if things run in parallel, like
for example (unless the async stuff can run in concurrently on one thread)
v
vineethraj49
04/03/2021, 1:10 AM
async stuff can run in concurrently on one thread => foo, bar, baz, and bax are suspending, and have suspension points in them ?
t
TwoClocks
04/03/2021, 5:18 AM
Yes. I use async quite a bit, but for my use-case I only run 1 thread. So I effectively have a bunch of "green threads" that are doing cooperative multitasking. And yes, every time they hit something that suspends, they effective give up control and let something else run.