org.eclipse.jetty.util.thread
Class ExecutorThreadPool
java.lang.Object
org.eclipse.jetty.util.component.AbstractLifeCycle
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
| Methods inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle |
addLifeCycleListener, getState, getState, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop, toString |
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)
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.