user3310917
user3310917

Reputation: 425

ExecutorCompletionService missing invokeAll interface

So reading the javadoc of ExecutorCompletionService, looks like it uses threadpoolexecutor that has methods like invokeAll(), however, the ExecutorCompletionService only provides submit() method, therefore not allowing us to call invokeAll and triggering all tasks at once if tasks are submitted through the ExecutorCompletionService.

Should not it support invokeAll() so that I can prepare a list of tasks and call something like

ExecutorCompletionService.invokeAll(listOfTasks);

instead of calling

ExecutorCompletionService.submit(task);

in a for loop?

Upvotes: 0

Views: 93

Answers (1)

Sotirios Delimanolis
Sotirios Delimanolis

Reputation: 279910

No. An ExecutorCompletionService is a CompletionService, not an ExecutorService. The whole point of a CompletionService is to provide a mechanism to check for completed tasks through polling.

invokeAll blocks until all submitted tasks are completed.

These are opposing features.

Upvotes: 2

Related Questions