ForkJoinTask.cancel

Attempts to cancel execution of this task. This attempt will fail if the task has already completed or could not be cancelled for some other reason. If successful, and this task has not started when {@code cancel} is called, execution of this task is suppressed. After this method returns successfully, unless there is an intervening call to {@link #reinitialize}, subsequent calls to {@link #isCancelled}, {@link #isDone}, and {@code cancel} will return {@code true} and calls to {@link #join} and related methods will result in {@code CancellationException}.

<p>This method may be overridden in subclasses, but if so, must still ensure that these properties hold. In particular, the {@code cancel} method itself must not throw exceptions.

<p>This method is designed to be invoked by <em>other</em> tasks. To terminate the current task, you can just return or throw an unchecked exception from its computation method, or invoke {@link #completeExceptionally(Throwable)}.

@param mayInterruptIfRunning this value has no effect in the default implementation because interrupts are not used to control cancellation.

@return {@code true} if this task is now cancelled

class ForkJoinTask(V)
bool
cancel

Meta