简体   繁体   中英

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM