Interface ListeningExecutorService
-
- All Superinterfaces:
Executor,ExecutorService
- All Known Subinterfaces:
ListeningScheduledExecutorService
- All Known Implementing Classes:
AbstractListeningExecutorService,ForwardingListeningExecutorService
public interface ListeningExecutorService extends ExecutorService
AnExecutorServicethat returnsListenableFutureinstances. To create an instance from an existingExecutorService, callMoreExecutors.listeningDecorator(ExecutorService).- Since:
- 10.0
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method 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)ListenableFuture<?>submit(Runnable task)<T> ListenableFuture<T>submit(Runnable task, T result)<T> ListenableFuture<T>submit(Callable<T> task)-
Methods inherited from interface java.util.concurrent.ExecutorService
awaitTermination, invokeAny, invokeAny, isShutdown, isTerminated, shutdown, shutdownNow
-
-
-
-
Method Detail
-
submit
<T> ListenableFuture<T> submit(Callable<T> task)
- Specified by:
submitin interfaceExecutorService- Returns:
- a
ListenableFuturerepresenting pending completion of the task - Throws:
RejectedExecutionException
-
submit
ListenableFuture<?> submit(Runnable task)
- Specified by:
submitin interfaceExecutorService- Returns:
- a
ListenableFuturerepresenting pending completion of the task - Throws:
RejectedExecutionException
-
submit
<T> ListenableFuture<T> submit(Runnable task, T result)
- Specified by:
submitin interfaceExecutorService- Returns:
- a
ListenableFuturerepresenting pending completion of the task - Throws:
RejectedExecutionException
-
invokeAll
<T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks) throws InterruptedException
All elements in the returned list must be
ListenableFutureinstances. The easiest way to obtain aList<ListenableFuture<T>>from this method is an unchecked (but safe) cast:@SuppressWarnings("unchecked") // guaranteed by invokeAll contractList<ListenableFuture<T>> futures = (List) executor.invokeAll(tasks);- Specified by:
invokeAllin interfaceExecutorService- Returns:
- A list of
ListenableFutureinstances representing the tasks, in the same sequential order as produced by the iterator for the given task list, each of which has completed. - Throws:
RejectedExecutionExceptionNullPointerException- if any task is nullInterruptedException
-
invokeAll
<T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) throws InterruptedException
All elements in the returned list must be
ListenableFutureinstances. The easiest way to obtain aList<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);- Specified by:
invokeAllin interfaceExecutorService- Returns:
- a list of
ListenableFutureinstances 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. - Throws:
RejectedExecutionExceptionNullPointerException- if any task is nullInterruptedException
-
-