Inconsistency in java.util.concurrent.Future?

Posted by loganj on Stack Overflow See other posts from Stack Overflow or by loganj
Published on 2010-06-03T15:20:04Z Indexed on 2010/06/03 15:24 UTC
Read the original article Hit count: 239

Filed under:
|
|

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 completed, 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)?

© Stack Overflow or respective owner

Related posts about java

Related posts about concurrency