112 |
|
* {@link CancellationException}. |
113 |
|
* |
114 |
|
* <p>By default, method {@link #cancel} ignores its {@code |
115 |
< |
* mayInterruptIfRunning} argument, to separate task cancellation from |
116 |
< |
* thread status. However, the method is overridable. An adaptor |
117 |
< |
* (@link #adaptInterruptible) for Callables does so by tracking and |
118 |
< |
* interrupting the running thread upon {@code cancel(true)}. Usage |
119 |
< |
* requires care. A late interrupt issued by another thread after the |
120 |
< |
* task has completed may (inadvertently) interrupt some future task. |
121 |
< |
* When using interruptible tasks, method bodies of all task code |
122 |
< |
* should ignore stray interrupts. When applicable, {@code |
123 |
< |
* isCancelled} or {@code isDone} can be used to distinguish cases. |
115 |
> |
* mayInterruptIfRunning} argument, separating task cancellation from |
116 |
> |
* the interruption status of threads running tasks. However, the |
117 |
> |
* method is overridable to accommodate cases in which running tasks |
118 |
> |
* must be cancelled using interrupts. This may arise when adapting |
119 |
> |
* Callables that cannot check {@code isCancelled()} task status. |
120 |
> |
* Tasks constructed with the (@link #adaptInterruptible) adaptor |
121 |
> |
* track and interrupt the running thread upon {@code |
122 |
> |
* cancel(true)}. Reliable usage requires awareness of potential |
123 |
> |
* consequences: Method bodies should ignore stray interrupts to cope |
124 |
> |
* with the inherent possibility that a late interrupt issued by |
125 |
> |
* another thread after a given task has completed may (inadvertently) |
126 |
> |
* interrupt some future task. Further, interruptible tasks should not |
127 |
> |
* in general create subtasks, because an interrupt intended for a |
128 |
> |
* given task may be consumed by one of its subtasks, or vice versa. |
129 |
|
* |
130 |
|
* <p>The ForkJoinTask class is not usually directly subclassed. |
131 |
|
* Instead, you subclass one of the abstract classes that support a |