ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/main/java/util/concurrent/Cancellable.java
Revision: 1.7
Committed: Tue Jun 24 14:34:47 2003 UTC (20 years, 11 months ago) by dl
Branch: MAIN
CVS Tags: JSR166_PRELIMINARY_TEST_RELEASE_2
Changes since 1.6: +10 -9 lines
Log Message:
Added missing javadoc tags; minor reformatting

File Contents

# Content
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 */
6
7 package java.util.concurrent;
8
9 /**
10 * 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 *
15 * @since 1.5
16 *
17 * @spec JSR-166
18 * @revised $Date: 2003/06/23 02:26:16 $
19 * @editor $Author: brian $
20 * @see FutureTask
21 * @see Executor
22 * @author Doug Lea
23 */
24 public interface Cancellable {
25
26 /**
27 * Attempt to cancel execution of this task. This attempt will
28 * fail if the task has already completed, already been cancelled,
29 * or could not be cancelled for some other reason. If successful,
30 * and this task has not started when <tt>cancel</tt> is called,
31 * this task will never run. If the task has already started,
32 * then the <tt>interruptIfRunning</tt> parameter determines
33 * whether the thread executing this task should be interrupted in
34 * an attempt to stop the task.
35 *
36 * @param mayInterruptIfRunning <tt>true</tt> if the thread executing this
37 * task should be interrupted; otherwise, in-progress tasks are allowed
38 * to complete
39 * @return <tt>false</tt> if the task could not be cancelled,
40 * typically because is has already completed normally;
41 * <tt>true</tt> otherwise
42 */
43 boolean cancel(boolean mayInterruptIfRunning);
44
45 /**
46 * Returns <tt>true</tt> if this task was cancelled before it completed
47 * normally.
48 *
49 * @return <tt>true</tt> if task was cancelled before it completed
50 */
51 boolean isCancelled();
52
53 /**
54 * Returns <tt>true</tt> if this task ran to completion or was cancelled.
55 *
56 * @return <tt>true</tt> if task completed normally or was cancelled
57 */
58 boolean isDone();
59 }