Interface ExecutorService
- All Superinterfaces:
Executor
- All Known Subinterfaces:
ScheduledExecutorService
- All Known Implementing Classes:
AbstractExecutorService
An
Executor that answers a Future for a submitted task and can be
shut down. Executors creates the implementations;
AbstractExecutorService provides everything but the execution itself.-
Method Summary
Modifier and TypeMethodDescriptionbooleanawaitTermination(long timeout, TimeUnit unit) Waits until the service has terminated or the time is up, and answers which of the two it was.invokeAll(Collection<? extends Callable<T>> tasks) Runs every task and answers their futures, all of them done.invokeAll(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) Runs every task and answers their futures once all are done or the time is up; the ones not done by then are cancelled.<T> TinvokeAny(Collection<? extends Callable<T>> tasks) The result of one of the tasks that completed without failing; the others are cancelled.<T> TinvokeAny(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) AsinvokeAny(Collection), giving up with aTimeoutExceptionwhen no task has succeeded in time.booleanbooleanWhether the service was shut down and every task it accepted has finished or been dropped.voidshutdown()Stops accepting tasks.Stops accepting tasks, drops the ones that have not started and answers them, and interrupts the ones that are running.Future<?> <T> Future<T> <T> Future<T>
-
Method Details
-
shutdown
void shutdown()Stops accepting tasks. The ones already submitted still run. -
shutdownNow
-
isShutdown
boolean isShutdown() -
isTerminated
boolean isTerminated()Whether the service was shut down and every task it accepted has finished or been dropped. -
awaitTermination
Waits until the service has terminated or the time is up, and answers which of the two it was.- Throws:
InterruptedException
-
submit
-
submit
-
submit
-
invokeAll
Runs every task and answers their futures, all of them done.- Throws:
InterruptedException
-
invokeAll
<T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) throws InterruptedException Runs every task and answers their futures once all are done or the time is up; the ones not done by then are cancelled.- Throws:
InterruptedException
-
invokeAny
<T> T invokeAny(Collection<? extends Callable<T>> tasks) throws InterruptedException, ExecutionException The result of one of the tasks that completed without failing; the others are cancelled. -
invokeAny
<T> T invokeAny(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException AsinvokeAny(Collection), giving up with aTimeoutExceptionwhen no task has succeeded in time.
-