I have N tasks, I want them to be processed in parallel with N threads. I want to wait until all tasks are finished, store results, and then run next N tasks (and so on in a loop).
Which abstractions from java util concurrency can help me here?
I looked at ExecutorService.invokeAll()
, but it returns a list of futures, so I should iterate all of them in a loop until all of them are done.
I thought, there should be more straightforward way to calculate a set of tasks.