org.jboss.threads
Class BalancingExecutor

java.lang.Object
  extended by org.jboss.threads.BalancingExecutor
All Implemented Interfaces:
java.util.concurrent.Executor

public class BalancingExecutor
extends java.lang.Object
implements java.util.concurrent.Executor

A simple load-balancing executor. If no delegate executors are defined, then tasks are rejected. Executors are chosen in a round-robin fashion.


Constructor Summary
BalancingExecutor()
          Construct a new instance.
BalancingExecutor(java.util.concurrent.Executor... executors)
          Construct a new instance.
 
Method Summary
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BalancingExecutor

public BalancingExecutor()
Construct a new instance.


BalancingExecutor

public BalancingExecutor(java.util.concurrent.Executor... executors)
Construct a new instance.

Parameters:
executors - the initial list of executors to delegate to
Method Detail

execute

public void execute(java.lang.Runnable command)
             throws java.util.concurrent.RejectedExecutionException
Execute a task.

Specified by:
execute in interface java.util.concurrent.Executor
Parameters:
command - the task to execute
Throws:
java.util.concurrent.RejectedExecutionException - if no executors are available to run the task

clear

public void clear()
Clear out all delegate executors at once. Tasks will be rejected until another delegate executor is added.


addExecutor

public void addExecutor(java.util.concurrent.Executor executor)
Add a delegate executor.

Parameters:
executor - the executor to add

removeExecutor

public void removeExecutor(java.util.concurrent.Executor executor)
Remove a delegate executor.

Parameters:
executor - the executor to remove


Copyright © 2011. All Rights Reserved.