AbstractExecutorService

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

Members

Functions

invokeAll
List!(Future!(T)) invokeAll(Collection!(Callable!(T)) tasks)
Undocumented in source. Be warned that the author may not have intended to support it.
invokeAll
List!(Future!(T)) invokeAll(Collection!(Callable!(T)) tasks, Duration timeout)
Undocumented in source. Be warned that the author may not have intended to support it.
invokeAny
T invokeAny(Collection!(Callable!(T)) tasks)
Undocumented in source. Be warned that the author may not have intended to support it.
invokeAny
T invokeAny(Collection!(Callable!(T)) tasks, Duration timeout)
Undocumented in source. Be warned that the author may not have intended to support it.
submit
Future!(void) submit(Runnable task)

@throws RejectedExecutionException {@inheritDoc} @throws NullPointerException {@inheritDoc}

submit
Future!(T) submit(Runnable task, T result)

@throws RejectedExecutionException {@inheritDoc} @throws NullPointerException {@inheritDoc}

submit
Future!(T) submit(Callable!(T) task)

@throws RejectedExecutionException {@inheritDoc} @throws NullPointerException {@inheritDoc}

Static functions

newTaskFor
RunnableFuture!(T) newTaskFor(Runnable runnable, T value)

Returns a {@code RunnableFuture} for the given runnable and default value.

newTaskFor
RunnableFuture!(T) newTaskFor(Runnable runnable)
Undocumented in source. Be warned that the author may not have intended to support it.
newTaskFor
RunnableFuture!(T) newTaskFor(Callable!(T) callable)

Returns a {@code RunnableFuture} for the given callable task.

Inherited Members

From ExecutorService

shutdown
void shutdown()

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.

shutdownNow
List!(Runnable) shutdownNow()

Attempts to stop all actively executing tasks, halts the processing of waiting tasks, and returns a list of the tasks that were awaiting execution.

isShutdown
bool isShutdown()

Returns {@code true} if this executor has been shut down.

isTerminated
bool isTerminated()

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.

awaitTermination
bool awaitTermination(Duration timeout)

Blocks until all tasks have completed execution after a shutdown request, or the timeout occurs, or the current thread is interrupted, whichever happens first.

Meta