Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: edu/emory/mathcs/util/concurrent/ExecutorService.java


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