ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/main/java/util/concurrent/Cancellable.java
Revision: 1.6
Committed: Mon Jun 23 02:26:16 2003 UTC (21 years ago) by brian
Branch: MAIN
Changes since 1.5: +7 -5 lines
Log Message:
Partial javadoc pass

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