org.eclipse.jetty.util.thread
Class ExecutorThreadPool

java.lang.Object
  extended by org.eclipse.jetty.util.component.AbstractLifeCycle
      extended by org.eclipse.jetty.util.thread.ExecutorThreadPool
All Implemented Interfaces:
LifeCycle, ThreadPool

public class ExecutorThreadPool
extends AbstractLifeCycle
implements ThreadPool, LifeCycle

Jetty ThreadPool using java 5 ThreadPoolExecutor This class wraps a ExecutorService as a ThreadPool and LifeCycle interfaces so that it may be used by the Jetty org.eclipse.jetty.server.Server


Nested Class Summary
 
Nested classes/interfaces inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
AbstractLifeCycle.AbstractLifeCycleListener
 
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.thread.ThreadPool
ThreadPool.SizedThreadPool
 
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.LifeCycle
LifeCycle.Listener
 
Field Summary
 
Fields inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
_listeners, FAILED, RUNNING, STARTED, STARTING, STOPPED, STOPPING
 
Constructor Summary
ExecutorThreadPool()
          constructor.
ExecutorThreadPool(ExecutorService executor)
           
ExecutorThreadPool(int queueSize)
          constructor.
ExecutorThreadPool(int corePoolSize, int maximumPoolSize, long keepAliveTime)
          constructor.
ExecutorThreadPool(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit)
          constructor.
ExecutorThreadPool(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue)
           
 
Method Summary
 boolean dispatch(Runnable job)
           
protected  void doStart()
           
protected  void doStop()
           
 int getIdleThreads()
           
 int getThreads()
           
 boolean isLowOnThreads()
           
 void join()
          Blocks until the thread pool is stopped.
 
Methods inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
addLifeCycleListener, getState, getState, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.eclipse.jetty.util.component.LifeCycle
addLifeCycleListener, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop
 

Constructor Detail

ExecutorThreadPool

public ExecutorThreadPool(ExecutorService executor)

ExecutorThreadPool

public ExecutorThreadPool()
constructor. Wraps an ThreadPoolExecutor. Core size is 32, max pool size is 256, pool thread timeout after 60 seconds and an unbounded LinkedBlockingQueue is used for the job queue;


ExecutorThreadPool

public ExecutorThreadPool(int queueSize)
constructor. Wraps an ThreadPoolExecutor. Core size is 32, max pool size is 256, pool thread timeout after 60 seconds

Parameters:
queueSize - if -1, an unbounded LinkedBlockingQueue is used, if 0 then a SynchronousQueue is used, other a ArrayBlockingQueue of the given size is used.

ExecutorThreadPool

public ExecutorThreadPool(int corePoolSize,
                          int maximumPoolSize,
                          long keepAliveTime)
constructor. Wraps an ThreadPoolExecutor using an unbounded LinkedBlockingQueue is used for the jobs queue;


ExecutorThreadPool

public ExecutorThreadPool(int corePoolSize,
                          int maximumPoolSize,
                          long keepAliveTime,
                          TimeUnit unit)
constructor. Wraps an ThreadPoolExecutor using an unbounded LinkedBlockingQueue is used for the jobs queue;


ExecutorThreadPool

public ExecutorThreadPool(int corePoolSize,
                          int maximumPoolSize,
                          long keepAliveTime,
                          TimeUnit unit,
                          BlockingQueue<Runnable> workQueue)
Method Detail

dispatch

public boolean dispatch(Runnable job)
Specified by:
dispatch in interface ThreadPool

getIdleThreads

public int getIdleThreads()
Specified by:
getIdleThreads in interface ThreadPool
Returns:
The number of idle threads in the pool

getThreads

public int getThreads()
Specified by:
getThreads in interface ThreadPool
Returns:
The total number of threads currently in the pool

isLowOnThreads

public boolean isLowOnThreads()
Specified by:
isLowOnThreads in interface ThreadPool
Returns:
True if the pool is low on threads

join

public void join()
          throws InterruptedException
Description copied from interface: ThreadPool
Blocks until the thread pool is stopped.

Specified by:
join in interface ThreadPool
Throws:
InterruptedException

doStart

protected void doStart()
                throws Exception
Overrides:
doStart in class AbstractLifeCycle
Throws:
Exception

doStop

protected void doStop()
               throws Exception
Overrides:
doStop in class AbstractLifeCycle
Throws:
Exception


Copyright © 1995-2011 Mort Bay Consulting. All Rights Reserved.