Just a quick coroutine question. All I want to do ...
# getting-started
p
Just a quick coroutine question. All I want to do is fire off a large number of calculations in the background, and wait for them to finish before continuing. I'm not interested in any results from them. How do I wait for all of them to finish ?
d
If you spawn all the coroutines in a
coroutineScope { .. }
, then the scope will wait for all the coroutines to finish before proceeding.
Or you can use
List<Job>.joinAll()
I think.
p
That did the trick, thanks !
(wrapped in a coroutineScope)
Also I realised I got no performance gain at all until I did launch(Dispatchers.Default) as I seemed to be running in a single thread regardless