public final class OrderedExecutor extends AbstractExecutorService implements BlockingExecutorService
execute(Runnable)
method that
happens-after another call A to the same method, will result in B's task running after A's.Constructor and Description |
---|
OrderedExecutor(Executor parent)
Construct a new instance using an unbounded FIFO queue.
|
OrderedExecutor(Executor parent,
int queueLength)
Construct a new instance using a bounded FIFO queue of the given size and a blocking reject policy.
|
OrderedExecutor(Executor parent,
int queueLength,
boolean blocking,
Executor handoffExecutor)
Construct a new instance using a bounded FIFO queue of the given size and a handoff reject policy.
|
OrderedExecutor(Executor parent,
int queueLength,
Executor handoffExecutor)
Construct a new instance using a bounded FIFO queue of the given size and a handoff reject policy.
|
OrderedExecutor(Executor parent,
Queue<Runnable> queue)
Construct a new instance using the given queue and a blocking reject policy.
|
OrderedExecutor(Executor parent,
Queue<Runnable> queue,
boolean blocking,
Executor handoffExecutor)
Construct a new instance.
|
Modifier and Type | Method and Description |
---|---|
boolean |
awaitTermination(long timeout,
TimeUnit unit) |
void |
execute(Runnable task)
Run a task.
|
void |
executeBlocking(Runnable task)
Execute a task, blocking until it can be accepted, or until the calling thread is interrupted.
|
void |
executeBlocking(Runnable task,
long timeout,
TimeUnit unit)
Execute a task, blocking until it can be accepted, a timeout elapses, or the calling thread is interrupted.
|
void |
executeNonBlocking(Runnable task)
Execute a task, without blocking.
|
boolean |
isShutdown() |
boolean |
isTerminated() |
void |
shutdown() |
List<Runnable> |
shutdownNow() |
invokeAll, invokeAll, invokeAny, invokeAny, newTaskFor, newTaskFor, submit, submit, submit
public OrderedExecutor(Executor parent)
parent
- the parent to delegate tasks topublic OrderedExecutor(Executor parent, Queue<Runnable> queue)
parent
- the parent to delegate tasks toqueue
- the queue to use to hold taskspublic OrderedExecutor(Executor parent, int queueLength)
parent
- the parent to delegate tasks toqueueLength
- the fixed length of the queue to use to hold taskspublic OrderedExecutor(Executor parent, int queueLength, Executor handoffExecutor)
parent
- the parent executorqueueLength
- the fixed length of the queue to use to hold taskshandoffExecutor
- the executor to hand tasks to if the queue is fullpublic OrderedExecutor(Executor parent, Queue<Runnable> queue, boolean blocking, Executor handoffExecutor)
parent
- the parent executorqueue
- the task queue to useblocking
- true
if rejected tasks should block, false
if rejected tasks should be handed offhandoffExecutor
- the executor to hand tasks to if the queue is fullpublic OrderedExecutor(Executor parent, int queueLength, boolean blocking, Executor handoffExecutor)
parent
- the parent executorqueueLength
- the fixed length of the queue to use to hold tasksblocking
- true
if rejected tasks should block, false
if rejected tasks should be handed offhandoffExecutor
- the executor to hand tasks to if the queue is fullpublic void execute(Runnable task)
execute
in interface Executor
execute
in interface BlockingExecutor
task
- the task to run.public void executeBlocking(Runnable task) throws RejectedExecutionException, InterruptedException
BlockingExecutor
executeBlocking
in interface BlockingExecutor
task
- the task to submitStoppedExecutorException
- if the executor was shut down before the task was acceptedThreadCreationException
- if a thread could not be created for some reasonRejectedExecutionException
- if execution is rejected for some other reasonInterruptedException
- if the current thread was interrupted before the task could be acceptedpublic void executeBlocking(Runnable task, long timeout, TimeUnit unit) throws RejectedExecutionException, InterruptedException
BlockingExecutor
executeBlocking
in interface BlockingExecutor
task
- the task to submittimeout
- the amount of time to waitunit
- the unit of timeExecutionTimedOutException
- if the timeout elapsed before a task could be acceptedStoppedExecutorException
- if the executor was shut down before the task was acceptedThreadCreationException
- if a thread could not be created for some reasonRejectedExecutionException
- if execution is rejected for some other reasonInterruptedException
- if the current thread was interrupted before the task could be acceptedpublic void executeNonBlocking(Runnable task) throws RejectedExecutionException
BlockingExecutor
executeNonBlocking
in interface BlockingExecutor
task
- the task to submitStoppedExecutorException
- if the executor was shut down before the task was acceptedThreadCreationException
- if a thread could not be created for some reasonRejectedExecutionException
- if execution is rejected for some other reasonpublic boolean isShutdown()
isShutdown
in interface ExecutorService
public boolean isTerminated()
isTerminated
in interface ExecutorService
public boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException
awaitTermination
in interface ExecutorService
InterruptedException
public void shutdown()
shutdown
in interface ExecutorService
public List<Runnable> shutdownNow()
shutdownNow
in interface ExecutorService
Copyright © 2012 JBoss by Red Hat. All Rights Reserved.