public class ExecutionService extends AbstractExecutorService
ExecutionRunner to start picking up requests.
Every future object returned will be a NotifyingFuture which
allows for not having to query the future and have a callback instead. This
can then be used as a workflow to submit other tasks sequentially or also to
query the future for the value at that time.
Every callable or runnable submitted must be either Serializable or
Streamable. Also the value returned from
a callable must Serializable or
Streamable. Unfortunately if the value returned is not serializable
then a NotSerializableException will be thrown as the cause.
| Modifier and Type | Class and Description |
|---|---|
static class |
ExecutionService.DistributedFuture<V>
This is basically a copy of the FutureTask in java.util.concurrent but
added serializable to it.
|
protected static class |
ExecutionService.RunnableAdapter<T>
This is copied from
Executors class which
contains RunnableAdapter. |
| Modifier and Type | Field and Description |
|---|---|
protected Executing |
_execProt |
protected AtomicBoolean |
_shutdown |
protected Condition |
_unfinishedCondition |
protected Set<Future<?>> |
_unfinishedFutures |
protected Lock |
_unfinishedLock |
protected JChannel |
ch |
| Constructor and Description |
|---|
ExecutionService() |
ExecutionService(JChannel ch) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
awaitTermination(long timeout,
TimeUnit unit) |
void |
execute(Runnable command) |
<T> T |
invokeAny(Collection<? extends Callable<T>> tasks) |
<T> T |
invokeAny(Collection<? extends Callable<T>> tasks,
long timeout,
TimeUnit unit) |
boolean |
isShutdown() |
boolean |
isTerminated() |
protected <T> RunnableFuture<T> |
newTaskFor(Callable<T> callable) |
protected <T> RunnableFuture<T> |
newTaskFor(Runnable runnable,
T value) |
void |
setChannel(JChannel ch) |
void |
shutdown() |
List<Runnable> |
shutdownNow() |
<T> NotifyingFuture<T> |
submit(Callable<T> task) |
<T> NotifyingFuture<T> |
submit(Runnable task,
T result) |
invokeAll, invokeAll, submitprotected JChannel ch
protected Executing _execProt
protected Lock _unfinishedLock
protected Condition _unfinishedCondition
protected AtomicBoolean _shutdown
public ExecutionService()
public ExecutionService(JChannel ch)
public void setChannel(JChannel ch)
public <T> NotifyingFuture<T> submit(Runnable task, T result)
submit in interface ExecutorServicesubmit in class AbstractExecutorServicepublic <T> NotifyingFuture<T> submit(Callable<T> task)
submit in interface ExecutorServicesubmit in class AbstractExecutorServicepublic void shutdown()
public boolean isShutdown()
public boolean isTerminated()
public boolean awaitTermination(long timeout,
TimeUnit unit)
throws InterruptedException
InterruptedExceptionpublic <T> T invokeAny(Collection<? extends Callable<T>> tasks) throws InterruptedException, ExecutionException
invokeAny in interface ExecutorServiceinvokeAny in class AbstractExecutorServiceInterruptedExceptionExecutionExceptionpublic <T> T invokeAny(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException
invokeAny in interface ExecutorServiceinvokeAny in class AbstractExecutorServiceInterruptedExceptionExecutionExceptionTimeoutExceptionpublic void execute(Runnable command)
protected <T> RunnableFuture<T> newTaskFor(Runnable runnable, T value)
newTaskFor in class AbstractExecutorServiceprotected <T> RunnableFuture<T> newTaskFor(Callable<T> callable)
newTaskFor in class AbstractExecutorServiceCopyright © 2012 JBoss by Red Hat. All Rights Reserved.