Tasks submitted to execute(Runnable) are executed in FIFO order.
The execution of tasks is done by one thread as long as there are tasks left in the queue.
When a task is interrupted, execution of subsequent tasks
continues. See QueueWorker#workOnQueue for details.
RuntimeExceptions thrown by tasks are simply logged and the executor keeps trucking.
If an Error is thrown, the error will propagate and execution will stop until it is
restarted by a call to execute.
| Modifier and Type | Class and Description |
|---|---|
| private class | SequentialExecutor.
Worker that runs tasks from |
| pack-priv static enum |
| Modifier and Type | Field and Description |
|---|---|
| private final Executor | executor
Underlying executor that all submitted Runnable objects are run on. |
| private static final LazyLogger | |
| private final Deque | |
| private final SequentialExecutor. | |
| private long | workerRunCount
This counter prevents an ABA issue where a thread may successfully schedule the worker, the worker runs and exhausts the queue, another thread enqueues a task and fails to schedule the worker, and then the first thread's call to delegate.execute() returns. |
| private SequentialExecutor. |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public void | execute(Runnable
the runnable task task)Implements java. |
| public String |
| executor | back to summary |
|---|---|
| private final Executor executor Underlying executor that all submitted Runnable objects are run on. | |
| log | back to summary |
|---|---|
| private static final LazyLogger log | |
| queue | back to summary |
|---|---|
private final Deque<Runnable> queue
| |
| worker | back to summary |
|---|---|
| private final SequentialExecutor. | |
| workerRunCount | back to summary |
|---|---|
| private long workerRunCount This counter prevents an ABA issue where a thread may successfully schedule the worker, the worker runs and exhausts the queue, another thread enqueues a task and fails to schedule the worker, and then the first thread's call to delegate.execute() returns. Without this counter, it would observe the QUEUING state and set it to QUEUED, and the worker would never be scheduled again for future submissions.
| |
| workerRunningState | back to summary |
|---|---|
private SequentialExecutor.
| |
| SequentialExecutor | back to summary |
|---|---|
| pack-priv SequentialExecutor(Executor executor) | |
| execute | back to summary |
|---|---|
| public void execute(Runnable task) Implements java. Adds a task to the queue and makes sure a worker thread is running. If this method throws, e.g. a
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns a string representation of the object. | |
queue until it is empty.
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public void | |
| public String | |
| private void |
| task | back to summary |
|---|---|
| pack-priv Runnable task
| |
| QueueWorker | back to summary |
|---|---|
| private QueueWorker() | |
| run | back to summary |
|---|---|
| public void run() Implements java. Doc from java. Runs this operation.
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns a string representation of the object.
| |
| workOnQueue | back to summary |
|---|---|
| private void workOnQueue() Continues executing tasks from The thread's interrupt bit is cleared before execution of each task. If the Thread in use is interrupted before or during execution of the tasks in
| |
| Modifier and Type | Field and Description |
|---|---|
| public static final SequentialExecutor. | IDLE
Runnable is not running and not queued for execution |
| public static final SequentialExecutor. | QUEUED
runnable has been submitted but has not yet begun execution |
| public static final SequentialExecutor. | QUEUING
Runnable is not running, but is being queued for execution |
| public static final SequentialExecutor. |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public static SequentialExecutor. | |
| public static SequentialExecutor. |
| IDLE | back to summary |
|---|---|
| public static final SequentialExecutor. Runnable is not running and not queued for execution | |
| QUEUED | back to summary |
|---|---|
| public static final SequentialExecutor. runnable has been submitted but has not yet begun execution | |
| QUEUING | back to summary |
|---|---|
| public static final SequentialExecutor. Runnable is not running, but is being queued for execution | |
| RUNNING | back to summary |
|---|---|
| public static final SequentialExecutor. | |
| WorkerRunningState | back to summary |
|---|---|
| private WorkerRunningState() | |
| valueOf | back to summary |
|---|---|
| public static SequentialExecutor. | |
| values | back to summary |
|---|---|
| public static SequentialExecutor. | |