[concurrency-interest] cancel method on Future API. Design rationale

Joe Bowbeer joe.bowbeer at gmail.com
Sat Apr 25 11:29:36 EDT 2009


The Future in j.u.c. is conceived as a promise to provide a value.  The
cancel method notifies it that there is no longer any interest in the value.

In practice, the Future is a handle for a runnable task submitted to an
executor.  Future is usually an instance of FutureTask, and in practice the
cancel method means "stop the task".  The mayInterrupt flag is a bit of
pragmatism leaking through, since effective cancellation may or may not
require that the running thread be interrupted.

I don't think of a Future as an Active Object.  I think of it as a two-way
message sent to an ActiveObject; cancel cancels the reply.

Joe

On Sat, Apr 25, 2009 at 4:58 AM, Unmesh joshi wrote:

>  Hi,
>
> Future class in util.concurrent has cancel method. Generally when designing
> Active Objects, what is the design rationale behind having a Cancel
> operation? In particular, because there is no guaranty that the task will
> actually cancelled (in case its completed)
>
> Thanks,
> Unmesh
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://cs.oswego.edu/pipermail/concurrency-interest/attachments/20090425/88c75467/attachment.html>


More information about the Concurrency-interest mailing list