开发者

Inconsistency in java.util.concurrent.Future?

For the sake of argument, let's say I'm implementing Future for a task which is not cancelable. The Java 6 API doc says:

After [cancel()] returns, subsequent calls to isDone() will always return true.

[cancel()] returns false if the task could not be cancelled, typically because it has already completed normally

It also says:

[isDone()] returns true if this task completed.

But what if my cancellation fails not because the task is already complete开发者_JS百科d, but because it simply cannot be cancelled? Is there a way out of this contradiction (other than making my uncancelable task cancelable and sidestepping it altogether)?


It does seem like the doc should say

After cancel() returns true, subsequent calls to isDone()...

The Javadocs are often flat-out wrong and contradictory, and Sun has often not even bothered to fix them even after 10 years. Careful testing should always supplement the docs.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜