/*
* Written by Doug Lea with assistance from members of JCP JSR-166
* Expert Group and released to the public domain. Use, modify, and
* redistribute this code in any way without acknowledgement.
*/
package java.util.concurrent;
/**
* Something (usually a task) that can be cancelled. Cancellation is
* performed by the cancel method. Additional methods are
* provided to determine if the task completed normally or was
* cancelled.
*
* @since 1.5
*
* @spec JSR-166
* @revised $Date: 2003/06/06 18:42:17 $
* @editor $Author: dl $
*/
public interface Cancellable {
/**
* Cancels execution of this task if it has not already completed.
* If this task has not started when cancel is called, this
* task will never run. If the task has already started, then
* the interruptIfRunning parameter determines whether the
* thread executing this task should be interrupted in an attempt to
* stop the task.
*
* @param interruptIfRunning true if the thread executing this
* task should be interrupted; otherwise, in-progress tasks are allowed
* to complete
* @return true if task has not already completed or been
* cancelled; false otherwise
*/
boolean cancel(boolean mayInterruptIfRunning);
/**
* Returns true if this task was cancelled before it completed
* normally.
*
* @return true if task was cancelled before it completed
*/
boolean isCancelled();
/**
* Returns true if this task ran to completion or was cancelled.
*
* @return true if task completed normally or was cancelled
*/
boolean isDone();
}