100 * public void run() {
101 * // read and service request on socket
102 * }
103 * }}</pre>
104 *
105 * The following method shuts down an {@code ExecutorService} in two phases,
106 * first by calling {@code shutdown} to reject incoming tasks, and then
107 * calling {@code shutdownNow}, if necessary, to cancel any lingering tasks:
108 *
109 * <pre> {@code
110 * void shutdownAndAwaitTermination(ExecutorService pool) {
111 * pool.shutdown(); // Disable new tasks from being submitted
112 * try {
113 * // Wait a while for existing tasks to terminate
114 * if (!pool.awaitTermination(60, TimeUnit.SECONDS)) {
115 * pool.shutdownNow(); // Cancel currently executing tasks
116 * // Wait a while for tasks to respond to being cancelled
117 * if (!pool.awaitTermination(60, TimeUnit.SECONDS))
118 * System.err.println("Pool did not terminate");
119 * }
120 * } catch (InterruptedException ie) {
121 * // (Re-)Cancel if current thread also interrupted
122 * pool.shutdownNow();
123 * // Preserve interrupt status
124 * Thread.currentThread().interrupt();
125 * }
126 * }}</pre>
127 *
128 * <p>Memory consistency effects: Actions in a thread prior to the
129 * submission of a {@code Runnable} or {@code Callable} task to an
130 * {@code ExecutorService}
131 * <a href="package-summary.html#MemoryVisibility"><i>happen-before</i></a>
132 * any actions taken by that task, which in turn <i>happen-before</i> the
133 * result is retrieved via {@code Future.get()}.
134 *
135 * @since 1.5
136 * @author Doug Lea
137 */
138 public interface ExecutorService extends Executor {
139
140 /**
|
100 * public void run() {
101 * // read and service request on socket
102 * }
103 * }}</pre>
104 *
105 * The following method shuts down an {@code ExecutorService} in two phases,
106 * first by calling {@code shutdown} to reject incoming tasks, and then
107 * calling {@code shutdownNow}, if necessary, to cancel any lingering tasks:
108 *
109 * <pre> {@code
110 * void shutdownAndAwaitTermination(ExecutorService pool) {
111 * pool.shutdown(); // Disable new tasks from being submitted
112 * try {
113 * // Wait a while for existing tasks to terminate
114 * if (!pool.awaitTermination(60, TimeUnit.SECONDS)) {
115 * pool.shutdownNow(); // Cancel currently executing tasks
116 * // Wait a while for tasks to respond to being cancelled
117 * if (!pool.awaitTermination(60, TimeUnit.SECONDS))
118 * System.err.println("Pool did not terminate");
119 * }
120 * } catch (InterruptedException ex) {
121 * // (Re-)Cancel if current thread also interrupted
122 * pool.shutdownNow();
123 * // Preserve interrupt status
124 * Thread.currentThread().interrupt();
125 * }
126 * }}</pre>
127 *
128 * <p>Memory consistency effects: Actions in a thread prior to the
129 * submission of a {@code Runnable} or {@code Callable} task to an
130 * {@code ExecutorService}
131 * <a href="package-summary.html#MemoryVisibility"><i>happen-before</i></a>
132 * any actions taken by that task, which in turn <i>happen-before</i> the
133 * result is retrieved via {@code Future.get()}.
134 *
135 * @since 1.5
136 * @author Doug Lea
137 */
138 public interface ExecutorService extends Executor {
139
140 /**
|