elizarov
11/29/2017, 10:20 AMjoin
if you rely on parent/child rels to split one large task into parallel subtasks. So, to do mySuspendingTask
100 times in parallel you can just do:
fun main(args: Array<String>) = runBlocking {
(0..100).forEach { launch(coroutineContext) { mySuspendingTask() } }
}
Now you are explicit about parallelism — you’ll launched concurrent subtask. No worries, since they are very cheap. You can run millions. You outer job (in this case — main) automatically waits for all the children to complete.gildor
11/29/2017, 10:21 AM