/* * @(#)Cancellable.java */ package java.util.concurrent; /** * An asynchronous 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/05/14 21:30:45 $ * @editor $Author: tim $ */ 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(); }