ExecutorCompletionService的疑问

java.util.concurrent中的ExecutorCompletionService,其实现的是CompletionService接口。

我对ExecutorCompletionService存在一个疑问,在其实现中,task是被执行之后,才把futureTask加入到completionQueue,既然如此,不如直接把Result加入到completionQueue中了。这个行为没什么差别的。对这个类的设计存在一些怀疑,我认为其task方法,似乎返回值是V更合适。

原来是这样的:
Future < V >  take()  throws  InterruptedException;
Future
< V >  poll();


觉得也许应该改称这样:
V take()  throws  InterruptedException;
V poll();

你可能感兴趣的:(ExecutorCompletionService的疑问)