@throws RejectedExecutionException {@inheritDoc} @throws NullPointerException {@inheritDoc}
@throws RejectedExecutionException {@inheritDoc} @throws NullPointerException {@inheritDoc}
@throws RejectedExecutionException {@inheritDoc} @throws NullPointerException {@inheritDoc}
Returns a {@code RunnableFuture} for the given runnable and default value.
Returns a {@code RunnableFuture} for the given callable task.
Initiates an orderly shutdown in which previously submitted tasks are executed, but no new tasks will be accepted. Invocation has no additional effect if already shut down.
Attempts to stop all actively executing tasks, halts the processing of waiting tasks, and returns a list of the tasks that were awaiting execution.
Returns {@code true} if this executor has been shut down.
Returns {@code true} if all tasks have completed following shut down. Note that {@code isTerminated} is never {@code true} unless either {@code shutdown} or {@code shutdownNow} was called first.
Blocks until all tasks have completed execution after a shutdown request, or the timeout occurs, or the current thread is interrupted, whichever happens first.
Provides default implementations of {@link ExecutorService} execution methods. This class implements the {@code submit}, {@code invokeAny} and {@code invokeAll} methods using a {@link RunnableFuture} returned by {@code newTaskFor}, which defaults to the {@link FutureTask} class provided in this package. For example, the implementation of {@code submit(Runnable)} creates an associated {@code RunnableFuture} that is executed and returned. Subclasses may override the {@code newTaskFor} methods to return {@code RunnableFuture} implementations other than {@code FutureTask}.
<p><b>Extension example</b>. Here is a sketch of a class that customizes {@link ThreadPoolExecutor} to use a {@code CustomTask} class instead of the default {@code FutureTask}: <pre> {@code class CustomThreadPoolExecutor extends ThreadPoolExecutor {
static class CustomTask!(V) : RunnableFuture!(V) {...}
protected !(V) RunnableFuture!(V) newTaskFor(Callable!(V) c) { return new CustomTask!(V)(c); } protected !(V) RunnableFuture!(V) newTaskFor(Runnable r, V v) { return new CustomTask!(V)(r, v); } // ... add constructors, etc. }}</pre>
@author Doug Lea