public class BalancingExecutor
extends java.lang.Object
implements java.util.concurrent.Executor
| Modifier and Type | Field and Description |
|---|---|
private java.util.concurrent.Executor[] |
executors |
private static AtomicArray<BalancingExecutor,java.util.concurrent.Executor> |
executorsUpdater |
private java.util.concurrent.atomic.AtomicInteger |
seq |
private java.util.concurrent.locks.Lock |
writeLock |
| Constructor and Description |
|---|
BalancingExecutor()
Construct a new instance.
|
BalancingExecutor(java.util.concurrent.Executor... executors)
Construct a new instance.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addExecutor(java.util.concurrent.Executor executor)
Add a delegate executor.
|
void |
clear()
Clear out all delegate executors at once.
|
void |
execute(java.lang.Runnable command)
Execute a task.
|
void |
removeExecutor(java.util.concurrent.Executor executor)
Remove a delegate executor.
|
private volatile java.util.concurrent.Executor[] executors
private final java.util.concurrent.atomic.AtomicInteger seq
private final java.util.concurrent.locks.Lock writeLock
private static final AtomicArray<BalancingExecutor,java.util.concurrent.Executor> executorsUpdater
public BalancingExecutor()
public BalancingExecutor(java.util.concurrent.Executor... executors)
executors - the initial list of executors to delegate topublic void execute(java.lang.Runnable command)
throws java.util.concurrent.RejectedExecutionException
execute in interface java.util.concurrent.Executorcommand - the task to executejava.util.concurrent.RejectedExecutionException - if no executors are available to run the taskpublic void clear()
public void addExecutor(java.util.concurrent.Executor executor)
executor - the executor to addpublic void removeExecutor(java.util.concurrent.Executor executor)
executor - the executor to remove