[concurrency-interest] overridden done method not working
dl at cs.oswego.edu
Tue Mar 7 07:48:25 EST 2006
Christopher Kin Chung Au wrote:
> The idea of what I am trying to do is to
> have a parent futuretask which creates multiple child futures. When I
> overrode the the done method on the parent futuretask and called
> cancel the done method does not get called immediate even though the
> iscancelled method and isdone method both return true. The overridden
> done method only gets called when all the child futures have finished
> executing. Is there somthing I am doing wrong???
The done method fires only when the task's run/call method returns,
not upon calling cancel. Apparently your parent tasks are written not
to return until child tasks complete.
If you require that cancelling a parent task should also cancel child
tasks, then you can override FutureTask.cancel (or make your own
custom Future implementation) to do this.
Also, your tasks should all make sure to be responsive to interrupts, perhaps by
interspersing "if (Thread.interrupted()) return..." as needed.
More information about the Concurrency-interest