Interface ExecutorService
- All Superinterfaces:
Executor
,ExecutorService
- All Known Subinterfaces:
ScheduledExecutorService
,ShutdownableExecutorService
,ShutdownableScheduledExecutorService
- All Known Implementing Classes:
ShutdownableExecutorServiceImpl
,ShutdownableScheduledExecutorServiceImpl
,ThreadPoolExecutor
,TimeScheduledThreadPoolExecutor
An analog to
ExecutorService
except that the futures
returned are AsyncFuture
s.-
Method Summary
Modifier and TypeMethodDescriptionAsyncFuture<?>
Submits a Runnable task for execution and returns a Future representing that task.<T> AsyncFuture<T>
Submits a Runnable task for execution and returns a Future representing that task.<T> AsyncFuture<T>
Submits a value-returning task for execution and returns a Future representing the pending results of the task.Methods inherited from interface java.util.concurrent.ExecutorService
awaitTermination, invokeAll, invokeAll, invokeAny, invokeAny, isShutdown, isTerminated, shutdown, shutdownNow
-
Method Details
-
submit
Submits a value-returning task for execution and returns a Future representing the pending results of the task. The Future'sget
method will return the task's result upon successful completion.If you would like to immediately block waiting for a task, you can use constructions of the form
result = exec.submit(aCallable).get();
Note: The
Executors
class includes a set of methods that can convert some other common closure-like objects, for example,PrivilegedAction
toCallable
form so they can be submitted.- Specified by:
submit
in interfaceExecutorService
- Type Parameters:
T
- the type of the task's result- Parameters:
task
- the task to submit- Returns:
- a Future representing pending completion of the task
- Throws:
RejectedExecutionException
- if the task cannot be scheduled for executionNullPointerException
- if the task is null
-
submit
Submits a Runnable task for execution and returns a Future representing that task. The Future'sget
method will return the given result upon successful completion.- Specified by:
submit
in interfaceExecutorService
- Type Parameters:
T
- the type of the result- Parameters:
task
- the task to submitresult
- the result to return- Returns:
- a Future representing pending completion of the task
- Throws:
RejectedExecutionException
- if the task cannot be scheduled for executionNullPointerException
- if the task is null
-
submit
Submits a Runnable task for execution and returns a Future representing that task. The Future'sget
method will returnnull
upon successful completion.- Specified by:
submit
in interfaceExecutorService
- Parameters:
task
- the task to submit- Returns:
- a Future representing pending completion of the task
- Throws:
RejectedExecutionException
- if the task cannot be scheduled for executionNullPointerException
- if the task is null
-