Class BalancingExecutor

java.lang.Object
org.jboss.threads.BalancingExecutor
All Implemented Interfaces:
Executor

public class BalancingExecutor extends Object implements Executor
A simple load-balancing executor. If no delegate executors are defined, then tasks are rejected. Executors are chosen in a random fashion.
  • Constructor Details

    • BalancingExecutor

      public BalancingExecutor()
      Construct a new instance.
    • BalancingExecutor

      public BalancingExecutor(Executor... executors)
      Construct a new instance.
      Parameters:
      executors - the initial list of executors to delegate to
  • Method Details

    • execute

      public void execute(Runnable command) throws RejectedExecutionException
      Execute a task.
      Specified by:
      execute in interface Executor
      Parameters:
      command - the task to execute
      Throws:
      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(Executor executor)
      Add a delegate executor.
      Parameters:
      executor - the executor to add
    • removeExecutor

      public void removeExecutor(Executor executor)
      Remove a delegate executor.
      Parameters:
      executor - the executor to remove