Andrea Giuliano
07/27/2020, 7:14 PMrunBlocking {
launch { dosomething }
launch { throw Exception }
}
This is nice because it make your thinking easier, and you are pretty much saying: here’s all I need to do, do that in parallel and in case something happens fail everything.
Now my question is this: what if I want to launch many coroutines that are independent from each other? I take the example of threadpool when on many threads you launch some operation but one thread throwing exception does not affect the others. Imagine that on each coroutine I’m handling a separate http request for example.
From the official doc, apart from handling explicitly the exception handling, I haven’t seen any of such examples and I wonder: is the price of launching coroutines that easy paid off when you really want to go in parallel with no noisy neighbours?runBlocking {
coroutineScope { launch { dosomething }}
coroutineScope { launch { throw Exception } }
}
and this isolates the scope of the different coroutines but still make them running on the same dispatcher/contextZach Klippenstein (he/him) [MOD]
07/27/2020, 7:48 PMAndrea Giuliano
07/27/2020, 7:50 PMZach Klippenstein (he/him) [MOD]
07/27/2020, 7:51 PM