Thursday 15 April 2010

How to run a set of tasks in parallel and wait until all of them are finished with java concurrency utils? -


I have an assignment, I want them to be processed parallel with N threads. I want to wait until all the tasks are finished, store the results, and then run the next N works (and in such a loop).

Which remnants from Java Usage concurrency can help me here?

I looked at ExecutorService.invokeAll () , but it gives a list of futures, so I should start all of them in a loop until all these Do not get well

I thought, there should be a simpler way to calculate a set of tasks.

You can use - it will get you those commands from future Allows to

You will still have a small loop, and the code you want to add will be after the loop after the completion of everything. I think that should be fine.

No comments:

Post a Comment