ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/main/java/util/concurrent/ExecutorService.java
Revision: 1.3
Committed: Tue Jun 3 16:44:36 2003 UTC (21 years ago) by dl
Branch: MAIN
Changes since 1.2: +12 -2 lines
Log Message:
New ScheduledExecutor; CancellableTask

File Contents

# User Rev Content
1 dl 1.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     import java.util.List;
10    
11     /**
12     * An executor that provides methods to manage termination. An
13     * <tt>ExecutorService</tt> can be shut down, which will cause it to
14     * stop accepting new tasks. After being shut down, the executor will
15     * eventually terminate, at which point no tasks are actively
16     * executing, no tasks are awaiting execution, and no new tasks can be
17     * submitted.
18     *
19     * <p>The <tt>Executors</tt> class provides factory methods for the
20 jozart 1.2 * executor services provided in <tt>java.util.concurrent</tt>.
21 dl 1.1 *
22     * @since 1.5
23     * @see Executors
24     *
25     * @spec JSR-166
26 dl 1.3 * @revised $Date: 2003/05/27 18:15:49 $
27     * @editor $Author: jozart $
28 dl 1.1 */
29     public interface ExecutorService extends Executor {
30    
31     /**
32     * Initiates an orderly shutdown in which previously submitted tasks
33     * are executed, but no new tasks will be accepted.
34     *
35     */
36     void shutdown();
37    
38     /**
39     * Attempts to stop all actively executing tasks, halts the
40     * processing of waiting tasks, and returns a list of the tasks that were
41     * awaiting execution.
42     *
43     * <p>There are no guarantees beyond best-effort attempts to stop
44     * processing actively executing tasks. For example, typical
45     * implementations will cancel via {@link Thread#interrupt}, so if any
46     * tasks mask or fail to respond to interrupts, they may never terminate.
47     *
48     * @return list of tasks that never commenced execution
49     */
50     List shutdownNow();
51    
52     /**
53     * Returns <tt>true</tt> if this executor has been shut down.
54     *
55     * @return <tt>true</tt> if this executor has been shut down
56     */
57     boolean isShutdown();
58    
59     /**
60     * Returns <tt>true</tt> if all tasks have completed following shut down.
61     * Note that <tt>isTerminated</tt> is never <tt>true</tt> unless
62     * either <tt>shutdown</tt> or <tt>shutdownNow</tt> was called first.
63     *
64     * @return <tt>true</tt> if all tasks have completed following shut down
65     */
66     boolean isTerminated();
67    
68     /**
69     * Blocks until all tasks have completed execution after a shutdown
70     * request, or the timeout occurs, or the current thread is
71     * interrupted, whichever happens first.
72     *
73     * @param timeout the maximum time to wait
74     * @param unit the time unit of the timeout argument
75     * @return <tt>true</tt> if this executor terminated and <tt>false</tt>
76     * if the timeout elapsed before termination
77     * @throws InterruptedException if interrupted while waiting
78     */
79     boolean awaitTermination(long timeout, TimeUnit unit)
80     throws InterruptedException;
81 dl 1.3
82    
83     /**
84     * Prevent this task from executing if it has not already
85     * commenced executing. This method provides only best-effort
86     * effects, and may fail for any reason.
87     * d
88     * #return true if the task was removed
89     */
90     boolean remove(Runnable task);
91 dl 1.1 }