1 |
tim |
1.1 |
/* |
2 |
dl |
1.2 |
* Written by Doug Lea with assistance from members of JCP JSR-166 |
3 |
|
|
* Expert Group and released to the public domain. Use, modify, and |
4 |
|
|
* redistribute this code in any way without acknowledgement. |
5 |
tim |
1.1 |
*/ |
6 |
|
|
|
7 |
|
|
package java.util.concurrent; |
8 |
|
|
|
9 |
|
|
/** |
10 |
dl |
1.3 |
* Something (usually a task) that can be cancelled. Cancellation is |
11 |
|
|
* performed by the <tt>cancel</tt> method. Additional methods are |
12 |
|
|
* provided to determine if the task completed normally or was |
13 |
|
|
* cancelled. |
14 |
tim |
1.1 |
* |
15 |
|
|
* @since 1.5 |
16 |
|
|
* |
17 |
|
|
* @spec JSR-166 |
18 |
dl |
1.3 |
* @revised $Date: 2003/05/27 18:14:39 $ |
19 |
|
|
* @editor $Author: dl $ |
20 |
tim |
1.1 |
*/ |
21 |
|
|
public interface Cancellable { |
22 |
|
|
|
23 |
|
|
/** |
24 |
|
|
* Cancels execution of this task if it has not already completed. |
25 |
|
|
* If this task has not started when <tt>cancel</tt> is called, this |
26 |
|
|
* task will never run. If the task has already started, then |
27 |
|
|
* the <tt>interruptIfRunning</tt> parameter determines whether the |
28 |
|
|
* thread executing this task should be interrupted in an attempt to |
29 |
|
|
* stop the task. |
30 |
|
|
* |
31 |
|
|
* @param interruptIfRunning <tt>true</tt> if the thread executing this |
32 |
|
|
* task should be interrupted; otherwise, in-progress tasks are allowed |
33 |
|
|
* to complete |
34 |
|
|
* @return <tt>true</tt> if task has not already completed or been |
35 |
|
|
* cancelled; <tt>false</tt> otherwise |
36 |
|
|
*/ |
37 |
|
|
boolean cancel(boolean mayInterruptIfRunning); |
38 |
|
|
|
39 |
|
|
/** |
40 |
|
|
* Returns <tt>true</tt> if this task was cancelled before it completed |
41 |
|
|
* normally. |
42 |
|
|
* |
43 |
|
|
* @return <tt>true</tt> if task was cancelled before it completed |
44 |
|
|
*/ |
45 |
|
|
boolean isCancelled(); |
46 |
|
|
|
47 |
|
|
/** |
48 |
|
|
* Returns <tt>true</tt> if this task ran to completion or was cancelled. |
49 |
|
|
* |
50 |
|
|
* @return <tt>true</tt> if task completed normally or was cancelled |
51 |
|
|
*/ |
52 |
|
|
boolean isDone(); |
53 |
|
|
} |