public interface XdevExecutorService extends Executor
Executor
that provides methods to manage termination and methods
that can produce a Future
for tracking progress of one or more
asynchronous tasks.
Method submit
extends base method Executor.execute(Runnable)
by creating and returning a Future
that can be used to cancel
execution and/or wait for completion. Methods invokeAny
and
invokeAll
perform the most commonly useful forms of bulk execution,
executing a collection of tasks and then waiting for at least one, or all, to
complete.
The instantiation and the shutdown process is handled by the framework. To use the executor just call one of the static get methods.
Application.getExecutorService()
Modifier and Type | Interface and Description |
---|---|
static interface |
XdevExecutorService.Factory |
static class |
XdevExecutorService.Implementation
Default implementation of the
XdevExecutorService contract. |
Modifier and Type | Field and Description |
---|---|
static String |
GRACEFUL_SHUTDOWN_INIT_PARAMETER |
static String |
THREAD_COUNT_INIT_PARAMETER |
Modifier and Type | Method and Description |
---|---|
void |
shutdown()
Initiates a shutdown of the executor service.
|
<T> Future<T> |
submit(Callable<T> task)
Submits a value-returning task for execution and returns a Future
representing the pending results of the task.
|
Future<?> |
submit(Runnable task)
Submits a Runnable task for execution and returns a Future representing
that task.
|
<T> Future<T> |
submit(Runnable task,
T result)
Submits a Runnable task for execution and returns a Future representing
that task.
|
static final String THREAD_COUNT_INIT_PARAMETER
static final String GRACEFUL_SHUTDOWN_INIT_PARAMETER
Future<?> submit(Runnable task)
get
method will return null
upon
successful completion.task
- the task to submitRejectedExecutionException
- if the task cannot be scheduled for executionNullPointerException
- if the task is null<T> Future<T> submit(Runnable task, T result)
get
method will return the given result
upon successful completion.T
- the type of the resulttask
- the task to submitresult
- the result to returnRejectedExecutionException
- if the task cannot be scheduled for executionNullPointerException
- if the task is null<T> Future<T> submit(Callable<T> task)
get
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();
T
- the type of the task's resulttask
- the task to submitRejectedExecutionException
- if the task cannot be scheduled for executionNullPointerException
- if the task is nullvoid shutdown()
Copyright © 2017 XDEV Software Corp.. All rights reserved.