I have a number of simultaneous tasks to run. If any of them fails, I want to interrupt them all and wait for completion. But, believing that none of them failed, I want to wait until they all end.
The ExecutorCompletionService seems almost what I want here, but there seems to be no way to determine if all my tasks are running, save for keeping a separate count of the number of tasks. (Note that both examples in the Javadoc for ExecutorCompletionService track the number of "n" tasks and use this to determine if the service has completed.)
Am I missing something, or do I really need to write this code myself?
java multithreading concurrency
Dan fabulich
source share