Class OrderedExecutor
java.lang.Object
java.util.concurrent.AbstractExecutorService
org.jboss.threads.OrderedExecutor
- All Implemented Interfaces:
Executor, ExecutorService, BlockingExecutor, BlockingExecutorService
public final class OrderedExecutor
extends AbstractExecutorService
implements BlockingExecutorService
An executor that always runs all tasks in queue order, using a delegate executor to run the tasks.
More specifically, if a FIFO queue type is used, any call B to the
execute(Runnable) method that
happens-after another call A to the same method, will result in B's task running after A's.-
Constructor Summary
ConstructorsConstructorDescriptionOrderedExecutor(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. -
Method Summary
Modifier and TypeMethodDescriptionbooleanawaitTermination(long timeout, TimeUnit unit) voidRun a task.voidexecuteBlocking(Runnable task) Deprecated.voidexecuteBlocking(Runnable task, long timeout, TimeUnit unit) Deprecated.voidexecuteNonBlocking(Runnable task) Deprecated.booleanbooleanvoidshutdown()Methods inherited from class AbstractExecutorService
invokeAll, invokeAll, invokeAny, invokeAny, newTaskFor, newTaskFor, submit, submit, submit
-
Constructor Details
-
OrderedExecutor
Construct a new instance using an unbounded FIFO queue. Since the queue is unbounded, tasks are never rejected.- Parameters:
parent- the parent to delegate tasks to
-
OrderedExecutor
-
OrderedExecutor
Construct a new instance using a bounded FIFO queue of the given size and a blocking reject policy.- Parameters:
parent- the parent to delegate tasks toqueueLength- the fixed length of the queue to use to hold tasks
-
OrderedExecutor
Construct a new instance using a bounded FIFO queue of the given size and a handoff reject policy.- Parameters:
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 full
-
OrderedExecutor
public OrderedExecutor(Executor parent, Queue<Runnable> queue, boolean blocking, Executor handoffExecutor) Construct a new instance.- Parameters:
parent- the parent executorqueue- the task queue to useblocking-trueif rejected tasks should block,falseif rejected tasks should be handed offhandoffExecutor- the executor to hand tasks to if the queue is full
-
OrderedExecutor
public 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.- Parameters:
parent- the parent executorqueueLength- the fixed length of the queue to use to hold tasksblocking-trueif rejected tasks should block,falseif rejected tasks should be handed offhandoffExecutor- the executor to hand tasks to if the queue is full
-
-
Method Details
-
execute
Run a task.- Specified by:
executein interfaceBlockingExecutor- Specified by:
executein interfaceExecutor- Parameters:
task- the task to run.
-
executeBlocking
@Deprecated public void executeBlocking(Runnable task) throws RejectedExecutionException, InterruptedException Deprecated.Description copied from interface:BlockingExecutorExecute a task, blocking until it can be accepted, or until the calling thread is interrupted.- Specified by:
executeBlockingin interfaceBlockingExecutor- Parameters:
task- the task to submit- Throws:
RejectedExecutionException- if execution is rejected for some other reasonInterruptedException- if the current thread was interrupted before the task could be accepted
-
executeBlocking
@Deprecated public void executeBlocking(Runnable task, long timeout, TimeUnit unit) throws RejectedExecutionException, InterruptedException Deprecated.Description copied from interface:BlockingExecutorExecute a task, blocking until it can be accepted, a timeout elapses, or the calling thread is interrupted.- Specified by:
executeBlockingin interfaceBlockingExecutor- Parameters:
task- the task to submittimeout- the amount of time to waitunit- the unit of time- Throws:
RejectedExecutionException- if execution is rejected for some other reasonInterruptedException- if the current thread was interrupted before the task could be accepted
-
executeNonBlocking
Deprecated.Description copied from interface:BlockingExecutorExecute a task, without blocking.- Specified by:
executeNonBlockingin interfaceBlockingExecutor- Parameters:
task- the task to submit- Throws:
RejectedExecutionException- if execution is rejected for some other reason
-
isShutdown
public boolean isShutdown()- Specified by:
isShutdownin interfaceExecutorService
-
isTerminated
public boolean isTerminated()- Specified by:
isTerminatedin interfaceExecutorService
-
awaitTermination
- Specified by:
awaitTerminationin interfaceExecutorService- Throws:
InterruptedException
-
shutdown
public void shutdown()- Specified by:
shutdownin interfaceExecutorService
-
shutdownNow
- Specified by:
shutdownNowin interfaceExecutorService
-