org.papoose.event.util
Class SerialExecutor

java.lang.Object
  extended by org.papoose.event.util.SerialExecutor
All Implemented Interfaces:
java.util.concurrent.Executor

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

A handy wrapper class that conveniently queues runnables for execution.

Use this class when you need to have multiple queues feeding a single thread pool.

Version:
$Revision: 228 $ $Date: 2010-01-12 13:40:06 -0800 (Tue, 12 Jan 2010) $

Constructor Summary
SerialExecutor(java.util.concurrent.Executor executor)
          Initialized the serial executor with a shared executor delegate.
 
Method Summary
 void execute(java.lang.Runnable runnable)
          Executes the given command at some time in the future.
protected  void scheduleNext()
          Poll the queue for more work.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SerialExecutor

public SerialExecutor(java.util.concurrent.Executor executor)
Initialized the serial executor with a shared executor delegate.

Parameters:
executor - the shared executor that is fed by this queue
Method Detail

execute

public void execute(java.lang.Runnable runnable)
Executes the given command at some time in the future. The command may execute in a new thread, in a pooled thread, or in the calling thread, at the discretion of the Executor that this class was constructed with.

Specified by:
execute in interface java.util.concurrent.Executor
Parameters:
runnable - the runnable task
Throws:
java.util.concurrent.RejectedExecutionException - if this task cannot be accepted for execution.
java.lang.NullPointerException - if command is null

scheduleNext

protected void scheduleNext()
Poll the queue for more work. If a runnable is found then send it to executor.



Copyright © 2010. All Rights Reserved.