public class ExecutionQueue extends Object
Runnable
s and executes on an Executor
, with
optional concurrency.
When concurrency = 1
(the default) submitted tasks are guaranteed to run serially and in the order submitted.
When concurrency > 1
there are no guarantees beyond the fact that tasks are still pulled from a queue to be
executed.
Constructor and Description |
---|
ExecutionQueue(Executor executor) |
ExecutionQueue(Executor executor,
int concurrencyLimit) |
Modifier and Type | Method and Description |
---|---|
void |
pause()
Pause execution of queued
Runnable s. |
void |
resume()
Resume execution of queued
Runnable s. |
void |
submit(Runnable runnable)
Submit a
Runnable to be executed. |
void |
submitToHead(Runnable runnable)
Submit a
Runnable to be executed at the head of the queue. |
public ExecutionQueue(Executor executor)
public ExecutionQueue(Executor executor, int concurrencyLimit)
public void submit(Runnable runnable)
Runnable
to be executed.runnable
- the Runnable
to be executed.public void submitToHead(Runnable runnable)
Runnable
to be executed at the head of the queue.runnable
- the Runnable
to be executed.public void pause()
Runnable
s.public void resume()
Runnable
s.Copyright © 2020. All rights reserved.