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 |
|
|
* An asynchronous task that can be cancelled. Cancellation is performed by |
11 |
|
|
* the <tt>cancel</tt> method. Additional methods are provided to determine |
12 |
|
|
* if the task completed normally or was cancelled. |
13 |
|
|
* |
14 |
|
|
* @since 1.5 |
15 |
|
|
* |
16 |
|
|
* @spec JSR-166 |
17 |
|
|
* @revised $Date: 2003/02/26 10:48:09 $ |
18 |
|
|
* @editor $Author: jozart $ |
19 |
|
|
*/ |
20 |
|
|
public interface Cancellable { |
21 |
|
|
|
22 |
|
|
/** |
23 |
|
|
* Cancels execution of this task if it has not already completed. |
24 |
|
|
* If this task has not started when <tt>cancel</tt> is called, this |
25 |
|
|
* task will never run. If the task has already started, then |
26 |
|
|
* the <tt>interruptIfRunning</tt> parameter determines whether the |
27 |
|
|
* thread executing this task should be interrupted in an attempt to |
28 |
|
|
* stop the task. |
29 |
|
|
* |
30 |
|
|
* @param interruptIfRunning <tt>true</tt> if the thread executing this |
31 |
|
|
* task should be interrupted; otherwise, in-progress tasks are allowed |
32 |
|
|
* to complete |
33 |
|
|
* @return <tt>true</tt> if task has not already completed or been |
34 |
|
|
* cancelled; <tt>false</tt> otherwise |
35 |
|
|
*/ |
36 |
|
|
boolean cancel(boolean mayInterruptIfRunning); |
37 |
|
|
|
38 |
|
|
/** |
39 |
|
|
* Returns <tt>true</tt> if this task was cancelled before it completed |
40 |
|
|
* normally. |
41 |
|
|
* |
42 |
|
|
* @return <tt>true</tt> if task was cancelled before it completed |
43 |
|
|
*/ |
44 |
|
|
boolean isCancelled(); |
45 |
|
|
|
46 |
|
|
/** |
47 |
|
|
* Returns <tt>true</tt> if this task ran to completion or was cancelled. |
48 |
|
|
* |
49 |
|
|
* @return <tt>true</tt> if task completed normally or was cancelled |
50 |
|
|
*/ |
51 |
|
|
boolean isDone(); |
52 |
|
|
} |