public class ExecutorThreadPool extends AbstractLifeCycle implements ThreadPool, LifeCycle
ExecutorService
as a ThreadPool
and
LifeCycle
interfaces so that it may be used by the Jetty org.eclipse.jetty.server.Server
AbstractLifeCycle.AbstractLifeCycleListener
ThreadPool.SizedThreadPool
LifeCycle.Listener
Constructor and Description |
---|
ExecutorThreadPool()
Wraps an
ThreadPoolExecutor . |
ExecutorThreadPool(ExecutorService executor) |
ExecutorThreadPool(int queueSize)
Wraps an
ThreadPoolExecutor . |
ExecutorThreadPool(int corePoolSize,
int maximumPoolSize,
long keepAliveTime)
Wraps an
ThreadPoolExecutor using
an unbounded LinkedBlockingQueue is used for the jobs queue; |
ExecutorThreadPool(int corePoolSize,
int maximumPoolSize,
long keepAliveTime,
TimeUnit unit)
Wraps an
ThreadPoolExecutor using
an unbounded LinkedBlockingQueue is used for the jobs queue. |
ExecutorThreadPool(int corePoolSize,
int maximumPoolSize,
long keepAliveTime,
TimeUnit unit,
BlockingQueue<Runnable> workQueue)
Wraps an
ThreadPoolExecutor |
Modifier and Type | Method and Description |
---|---|
boolean |
dispatch(Runnable job) |
protected void |
doStop() |
void |
execute(Runnable job) |
int |
getIdleThreads() |
int |
getThreads() |
boolean |
isLowOnThreads() |
void |
join()
Blocks until the thread pool is
stopped . |
addLifeCycleListener, doStart, getState, getState, getStopTimeout, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, setStopTimeout, start, stop
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addLifeCycleListener, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop
public ExecutorThreadPool(ExecutorService executor)
public ExecutorThreadPool()
ThreadPoolExecutor
.
Max pool size is 256, pool thread timeout after 60 seconds and
an unbounded LinkedBlockingQueue
is used for the job queue;public ExecutorThreadPool(int queueSize)
ThreadPoolExecutor
.
Max pool size is 256, pool thread timeout after 60 seconds, and core pool size is 32 when queueSize >= 0.queueSize
- can be -1 for using an unbounded LinkedBlockingQueue
, 0 for using a
SynchronousQueue
, greater than 0 for using a ArrayBlockingQueue
of the given size.public ExecutorThreadPool(int corePoolSize, int maximumPoolSize, long keepAliveTime)
ThreadPoolExecutor
using
an unbounded LinkedBlockingQueue
is used for the jobs queue;corePoolSize
- must be equal to maximumPoolSizemaximumPoolSize
- the maximum number of threads to allow in the poolkeepAliveTime
- the max time a thread can remain idle, in millisecondspublic ExecutorThreadPool(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit)
ThreadPoolExecutor
using
an unbounded LinkedBlockingQueue
is used for the jobs queue.corePoolSize
- must be equal to maximumPoolSizemaximumPoolSize
- the maximum number of threads to allow in the poolkeepAliveTime
- the max time a thread can remain idleunit
- the unit for the keepAliveTimepublic ExecutorThreadPool(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue)
ThreadPoolExecutor
corePoolSize
- the number of threads to keep in the pool, even if they are idlemaximumPoolSize
- the maximum number of threads to allow in the poolkeepAliveTime
- the max time a thread can remain idleunit
- the unit for the keepAliveTimeworkQueue
- the queue to use for holding tasks before they are executedpublic boolean dispatch(Runnable job)
public int getIdleThreads()
getIdleThreads
in interface ThreadPool
public int getThreads()
getThreads
in interface ThreadPool
public boolean isLowOnThreads()
isLowOnThreads
in interface ThreadPool
public void join() throws InterruptedException
ThreadPool
stopped
.join
in interface ThreadPool
InterruptedException
protected void doStop() throws Exception
doStop
in class AbstractLifeCycle
Exception
Copyright © 1995-2015 Webtide. All Rights Reserved.