org.mortbay.thread.concurrent
public class ThreadPool extends ThreadPoolExecutor implements org.mortbay.thread.ThreadPool, org.mortbay.component.LifeCycle
ThreadPoolExecutor
with the ThreadPool
and
LifeCycle
interfaces so that it may be used by the Jetty org.mortbay.jetty.Server
ThreadPoolExecutor.AbortPolicy, ThreadPoolExecutor.CallerRunsPolicy, ThreadPoolExecutor.DiscardOldestPolicy, ThreadPoolExecutor.DiscardPolicy
Constructor and Description |
---|
ThreadPool()
Default constructor.
|
ThreadPool(int queueSize)
Default constructor.
|
ThreadPool(int corePoolSize,
int maximumPoolSize,
long keepAliveTime,
TimeUnit unit)
Size constructor.
|
ThreadPool(int corePoolSize,
int maximumPoolSize,
long keepAliveTime,
TimeUnit unit,
BlockingQueue<Runnable> workQueue) |
ThreadPool(int corePoolSize,
int maximumPoolSize,
long keepAliveTime,
TimeUnit unit,
BlockingQueue<Runnable> workQueue,
RejectedExecutionHandler handler) |
ThreadPool(int corePoolSize,
int maximumPoolSize,
long keepAliveTime,
TimeUnit unit,
BlockingQueue<Runnable> workQueue,
ThreadFactory threadFactory) |
ThreadPool(int corePoolSize,
int maximumPoolSize,
long keepAliveTime,
TimeUnit unit,
BlockingQueue<Runnable> workQueue,
ThreadFactory threadFactory,
RejectedExecutionHandler handler) |
Modifier and Type | Method and Description |
---|---|
void |
addLifeCycleListener(org.mortbay.component.LifeCycle.Listener listener) |
boolean |
dispatch(Runnable job) |
int |
getIdleThreads() |
int |
getThreads() |
boolean |
isFailed() |
boolean |
isLowOnThreads() |
boolean |
isRunning() |
boolean |
isStarted() |
boolean |
isStarting() |
boolean |
isStopped() |
boolean |
isStopping() |
void |
join() |
void |
removeLifeCycleListener(org.mortbay.component.LifeCycle.Listener listener) |
void |
start() |
void |
stop() |
afterExecute, allowCoreThreadTimeOut, allowsCoreThreadTimeOut, awaitTermination, beforeExecute, execute, finalize, getActiveCount, getCompletedTaskCount, getCorePoolSize, getKeepAliveTime, getLargestPoolSize, getMaximumPoolSize, getPoolSize, getQueue, getRejectedExecutionHandler, getTaskCount, getThreadFactory, isShutdown, isTerminated, isTerminating, prestartAllCoreThreads, prestartCoreThread, purge, remove, setCorePoolSize, setKeepAliveTime, setMaximumPoolSize, setRejectedExecutionHandler, setThreadFactory, shutdown, shutdownNow, terminated
invokeAll, invokeAll, invokeAny, invokeAny, newTaskFor, newTaskFor, submit, submit, submit
public ThreadPool()
LinkedBlockingQueue
is used for the job queue;public ThreadPool(int queueSize)
queueSize
- if -1, an unbounded LinkedBlockingQueue
is used, if 0 then a
SynchronousQueue
is used, other a ArrayBlockingQueue
of the given size is used.public ThreadPool(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit)
LinkedBlockingQueue
is used for the jobs queue;public ThreadPool(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue)
public ThreadPool(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue, RejectedExecutionHandler handler)
public ThreadPool(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue, ThreadFactory threadFactory, RejectedExecutionHandler handler)
public ThreadPool(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue, ThreadFactory threadFactory)
public boolean dispatch(Runnable job)
dispatch
in interface org.mortbay.thread.ThreadPool
public int getIdleThreads()
getIdleThreads
in interface org.mortbay.thread.ThreadPool
public int getThreads()
getThreads
in interface org.mortbay.thread.ThreadPool
public boolean isLowOnThreads()
isLowOnThreads
in interface org.mortbay.thread.ThreadPool
public void join() throws InterruptedException
join
in interface org.mortbay.thread.ThreadPool
InterruptedException
public boolean isFailed()
isFailed
in interface org.mortbay.component.LifeCycle
public boolean isRunning()
isRunning
in interface org.mortbay.component.LifeCycle
public boolean isStarted()
isStarted
in interface org.mortbay.component.LifeCycle
public boolean isStarting()
isStarting
in interface org.mortbay.component.LifeCycle
public boolean isStopped()
isStopped
in interface org.mortbay.component.LifeCycle
public boolean isStopping()
isStopping
in interface org.mortbay.component.LifeCycle
public void start() throws Exception
start
in interface org.mortbay.component.LifeCycle
Exception
public void stop() throws Exception
stop
in interface org.mortbay.component.LifeCycle
Exception
public void addLifeCycleListener(org.mortbay.component.LifeCycle.Listener listener)
addLifeCycleListener
in interface org.mortbay.component.LifeCycle
public void removeLifeCycleListener(org.mortbay.component.LifeCycle.Listener listener)
removeLifeCycleListener
in interface org.mortbay.component.LifeCycle
Copyright © 2009 Mortbay Consulting Pty. Ltd. All Rights Reserved.