ExecutorCompletionService? Why do need one if we have invokeAll?

后端 未结 4 1739
渐次进展
渐次进展 2020-12-04 09:48

If we use an ExecutorCompletionService we can submit a series of tasks as Callables and get the result interacting with the CompletionService as a

4条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-04 10:34

    I haven't ever actually used ExecutorCompletionService, but I think the case where this could be more useful than "normal" ExecutorService would be when you want to receive the Futures of completed tasks in completion order. With invokeAll, you just get a list that can contain a mix of incomplete and completed tasks at any given time.

提交回复
热议问题