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