ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/main/java/util/concurrent/Cancellable.java
Revision: 1.5
Committed: Sat Jun 21 12:23:28 2003 UTC (20 years, 11 months ago) by dl
Branch: MAIN
Changes since 1.4: +13 -10 lines
Log Message:
Weakened spec for cancel method

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