public class SequentialExecutionQueue extends Object implements Executor
Executor that collapses two equal Runnables into one,
and makes sure no two equal Runnables get executed simultaneously.
That is, if a Runnable is executing and another one gets submitted,
the 2nd one waits for the completion of the 1st one.
Object.equals(Object) is used on Runnable to identify
two equal Runnables.
| Constructor and Description |
|---|
SequentialExecutionQueue(ExecutorService executors) |
| Modifier and Type | Method and Description |
|---|---|
void |
execute(Runnable item) |
ExecutorService |
getExecutors()
Gets the base underlying executors.,
|
Set<Runnable> |
getInProgress()
Gets
Runnables that are currently executed by a live thread. |
boolean |
isStarving(long threshold)
Returns true if too much time is spent since some
Runnable is submitted into the queue
until they get executed. |
void |
setExecutors(ExecutorService svc)
Starts using a new
ExecutorService to carry out executions. |
public SequentialExecutionQueue(ExecutorService executors)
public ExecutorService getExecutors()
public void setExecutors(ExecutorService svc)
ExecutorService to carry out executions.
The older ExecutorService will be shut down (but it's still expected to
complete whatever they are doing and scheduled.)
public boolean isStarving(long threshold)
Runnable is submitted into the queue
until they get executed.Copyright © 2019. All rights reserved.