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();

posted on 2006-11-13 20:11  温少  阅读(2515)  评论(1编辑  收藏  举报

导航