@Beta public abstract class AbstractListeningExecutorService extends Object implements ListeningExecutorService
ListeningExecutorService execution methods atop the abstract Executor.execute(java.lang.Runnable)
method. More concretely, the submit, invokeAny and invokeAll methods
create ListenableFutureTask instances and pass them to Executor.execute(java.lang.Runnable).
In addition to Executor.execute(java.lang.Runnable), subclasses must implement all methods related to shutdown and
termination.
| Constructor and Description |
|---|
AbstractListeningExecutorService() |
| Modifier and Type | Method and Description |
|---|---|
<T> List<Future<T>> |
invokeAll(Collection<? extends Callable<T>> tasks) |
<T> List<Future<T>> |
invokeAll(Collection<? extends Callable<T>> tasks,
long timeout,
TimeUnit unit) |
<T> T |
invokeAny(Collection<? extends Callable<T>> tasks) |
<T> T |
invokeAny(Collection<? extends Callable<T>> tasks,
long timeout,
TimeUnit unit) |
<T> ListenableFuture<T> |
submit(Callable<T> task) |
ListenableFuture<?> |
submit(Runnable task) |
<T> ListenableFuture<T> |
submit(Runnable task,
T result) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitawaitTermination, isShutdown, isTerminated, shutdown, shutdownNowpublic AbstractListeningExecutorService()
public ListenableFuture<?> submit(Runnable task)
submit in interface ListeningExecutorServicesubmit in interface ExecutorServiceListenableFuture representing pending completion of the taskpublic <T> ListenableFuture<T> submit(Runnable task, @Nullable T result)
submit in interface ListeningExecutorServicesubmit in interface ExecutorServiceListenableFuture representing pending completion of the taskpublic <T> ListenableFuture<T> submit(Callable<T> task)
submit in interface ListeningExecutorServicesubmit in interface ExecutorServiceListenableFuture representing pending completion of the taskpublic <T> T invokeAny(Collection<? extends Callable<T>> tasks) throws InterruptedException, ExecutionException
invokeAny in interface ExecutorServiceInterruptedExceptionExecutionExceptionpublic <T> T invokeAny(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException
invokeAny in interface ExecutorServiceInterruptedExceptionExecutionExceptionTimeoutExceptionpublic <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks) throws InterruptedException
ListeningExecutorServiceAll elements in the returned list must be ListenableFuture instances. The easiest
way to obtain a List<ListenableFuture<T>> from this method is an unchecked (but safe)
cast:
@SuppressWarnings("unchecked") // guaranteed by invokeAll contractList<ListenableFuture<T>> futures = (List) executor.invokeAll(tasks);
invokeAll in interface ListeningExecutorServiceinvokeAll in interface ExecutorServiceListenableFuture instances representing the tasks, in the same
sequential order as produced by the iterator for the given task list, each of which has
completed.InterruptedExceptionpublic <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) throws InterruptedException
ListeningExecutorServiceAll elements in the returned list must be ListenableFuture instances. The easiest
way to obtain a List<ListenableFuture<T>> from this method is an unchecked (but safe)
cast:
@SuppressWarnings("unchecked") // guaranteed by invokeAll contractList<ListenableFuture<T>> futures = (List) executor.invokeAll(tasks, timeout, unit);
invokeAll in interface ListeningExecutorServiceinvokeAll in interface ExecutorServiceListenableFuture instances representing the tasks, in the same
sequential order as produced by the iterator for the given task list. If the operation
did not time out, each task will have completed. If it did time out, some of these
tasks will not have completed.InterruptedExceptionCopyright © 2010-2014. All Rights Reserved.