[concurrency-interest] cancellation of ForkJoinTask
dl at cs.oswego.edu
Fri May 7 10:42:47 EDT 2010
On 05/07/10 09:14, Denys Geert wrote:
>> From my observations, when canceling a top-level recursive task submitted
>> to FJ, the thread that called FJPool.invoke is unblocked quite rapidly, but
>> the task and its child tasks keep on executing in the FJ pool (even forking
>> and joining new child tasks).
> Although the cancellation has the effect of unblocking the invoker, it seem
> all of the work is still performed, as if cancellation was never requested.
> The behavior of the cancellation seems weird and not very helpful. An
> alternative would be to shut the FJ pool down, but that would prevent reuse
> of the pool among tasks.
If you need to somehow return early from a task that is running
while asynchronously cancelled, then task compute method itself must
check isCancelled and respond appropriately (which may include
propagating cancellation to subtasks). We (the FJ framework)
cannot do this for you because we know nothing about the internals
of compute() methods. And even if we did, we would not always
know the appropriate action.
More information about the Concurrency-interest