ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/main/java/util/concurrent/ExecutorService.java
Revision: 1.6
Committed: Sun Aug 24 14:47:31 2003 UTC (20 years, 9 months ago) by dl
Branch: MAIN
Changes since 1.5: +5 -3 lines
Log Message:
Javadoc clarifications

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.6 * @revised $Date: 2003/06/24 14:34:48 $
27 dl 1.4 * @editor $Author: dl $
28 dl 1.5 * @author Doug Lea
29 dl 1.1 */
30     public interface ExecutorService extends Executor {
31    
32     /**
33 dl 1.6 * Initiates an orderly shutdown in which previously submitted
34     * tasks are executed, but no new tasks will be
35     * accepted. Invocation has no additional effect if already shut
36     * down.
37 dl 1.1 *
38     */
39     void shutdown();
40    
41     /**
42     * Attempts to stop all actively executing tasks, halts the
43     * processing of waiting tasks, and returns a list of the tasks that were
44     * awaiting execution.
45     *
46     * <p>There are no guarantees beyond best-effort attempts to stop
47     * processing actively executing tasks. For example, typical
48     * implementations will cancel via {@link Thread#interrupt}, so if any
49     * tasks mask or fail to respond to interrupts, they may never terminate.
50     *
51     * @return list of tasks that never commenced execution
52     */
53     List shutdownNow();
54    
55     /**
56     * Returns <tt>true</tt> if this executor has been shut down.
57     *
58     * @return <tt>true</tt> if this executor has been shut down
59     */
60     boolean isShutdown();
61    
62     /**
63     * Returns <tt>true</tt> if all tasks have completed following shut down.
64     * Note that <tt>isTerminated</tt> is never <tt>true</tt> unless
65     * either <tt>shutdown</tt> or <tt>shutdownNow</tt> was called first.
66     *
67     * @return <tt>true</tt> if all tasks have completed following shut down
68     */
69     boolean isTerminated();
70    
71     /**
72     * Blocks until all tasks have completed execution after a shutdown
73     * request, or the timeout occurs, or the current thread is
74     * interrupted, whichever happens first.
75     *
76     * @param timeout the maximum time to wait
77     * @param unit the time unit of the timeout argument
78     * @return <tt>true</tt> if this executor terminated and <tt>false</tt>
79     * if the timeout elapsed before termination
80     * @throws InterruptedException if interrupted while waiting
81     */
82     boolean awaitTermination(long timeout, TimeUnit unit)
83     throws InterruptedException;
84 dl 1.3
85 dl 1.1 }