parallelDoThen

fun <E> Collection<E>.parallelDoThen(action: (E, () -> Unit) -> Unit, then: () -> Unit)

For each element in the collection, execute the action, passing a zero-argument function to run exactly once afterward (in this Thread or another). When the last element's zero-argument function has been invoked, or immediately if the collection is empty, invoke then.

Parameters

action

What to do with each element. It should invoke the second argument when processing of that element is considered complete.

then

What to do after each element has reported completion.