[concurrency-interest]yet another proposal for Executor

David Holmes dholmes@dltech.com.au
Thu, 7 Feb 2002 07:56:20 +1000


Mark D. Anderson wrote:
> public interface Callable {
>   Object call() throws Exception;
>   /** to be called before interrupting or unqueueing */
>   void cancel();
> }

I'm a little unclear on exactly how cancel() is intended to be used. From
what I recall it is meant to be a "cleanup function" of some sorts, but is
to be called *before* actually unqueing/interrupting - right? But if it is
called before unqueuing then cancel() and run() have to coordinate to ensure
that if the task is executed before it is unqueued then it won't do anything
that conflicts with the cancel (presumably check a cancel flag and return).
But if that is the case then why not unqueue the task first? It would seem
to me that it is far easier for cancel() to work out what to do if it knows
that none of the tasks in the group can still execute.

David Holmes