下面的代码是从AbstractExecutorService:为什么类调用RunnableFuture <T>而不是CallableFuture <T>?
/**
* Returns a <tt>RunnableFuture</tt> for the given callable task.
*
* @param callable the callable task being wrapped
* @return a <tt>RunnableFuture</tt> which when run will call the
* underlying callable and which, as a <tt>Future</tt>, will yield
* the callable's result as its result and provide for
* cancellation of the underlying task.
* @since 1.6
*/
protected <T> RunnableFuture<T> newTaskFor(Callable<T> callable) {
return new FutureTask<T>(callable);
}
我看不出为什么类从newTaskFor()
返回对象将被称为RunnableFuture代替CallableFuture?我在这里错过了什么?
调用的'()的签名'方法是这样的'V()调用抛出异常;'。通过我的意思是说他们为什么不把一个'V()调用抛出异常的问题;'方法和名称它CallableFurture,因为他们在这里做的是他们正在''可调用''FutureTask' – Inquisitive 2012-07-11 08:10:30
@Subhra包装'然后我建议你相应地编辑你的问题。 – EJP 2012-07-11 08:38:06