org.mortbay.thread.concurrent
Class ThreadPool
java.lang.Object
java.util.concurrent.AbstractExecutorService
java.util.concurrent.ThreadPoolExecutor
org.mortbay.thread.concurrent.ThreadPool
- All Implemented Interfaces:
- java.util.concurrent.Executor, java.util.concurrent.ExecutorService, LifeCycle, ThreadPool
public class ThreadPool
- extends java.util.concurrent.ThreadPoolExecutor
- implements ThreadPool, LifeCycle
Jetty ThreadPool using java 5 ThreadPoolExecutor
This class wraps a ThreadPoolExecutor with the ThreadPool and
LifeCycle interfaces so that it may be used by the Jetty Server
- Author:
- gregw
| Nested classes/interfaces inherited from class java.util.concurrent.ThreadPoolExecutor |
java.util.concurrent.ThreadPoolExecutor.AbortPolicy, java.util.concurrent.ThreadPoolExecutor.CallerRunsPolicy, java.util.concurrent.ThreadPoolExecutor.DiscardOldestPolicy, java.util.concurrent.ThreadPoolExecutor.DiscardPolicy |
|
Constructor Summary |
ThreadPool()
Default constructor. |
ThreadPool(int queueSize)
Default constructor. |
ThreadPool(int corePoolSize,
int maximumPoolSize,
long keepAliveTime,
java.util.concurrent.TimeUnit unit)
Size constructor. |
ThreadPool(int corePoolSize,
int maximumPoolSize,
long keepAliveTime,
java.util.concurrent.TimeUnit unit,
java.util.concurrent.BlockingQueue<java.lang.Runnable> workQueue)
|
ThreadPool(int corePoolSize,
int maximumPoolSize,
long keepAliveTime,
java.util.concurrent.TimeUnit unit,
java.util.concurrent.BlockingQueue<java.lang.Runnable> workQueue,
java.util.concurrent.RejectedExecutionHandler handler)
|
ThreadPool(int corePoolSize,
int maximumPoolSize,
long keepAliveTime,
java.util.concurrent.TimeUnit unit,
java.util.concurrent.BlockingQueue<java.lang.Runnable> workQueue,
java.util.concurrent.ThreadFactory threadFactory)
|
ThreadPool(int corePoolSize,
int maximumPoolSize,
long keepAliveTime,
java.util.concurrent.TimeUnit unit,
java.util.concurrent.BlockingQueue<java.lang.Runnable> workQueue,
java.util.concurrent.ThreadFactory threadFactory,
java.util.concurrent.RejectedExecutionHandler handler)
|
| Methods inherited from class java.util.concurrent.ThreadPoolExecutor |
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 |
| Methods inherited from class java.util.concurrent.AbstractExecutorService |
invokeAll, invokeAll, invokeAny, invokeAny, newTaskFor, newTaskFor, submit, submit, submit |
| Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ThreadPool
public ThreadPool()
- Default constructor.
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;
ThreadPool
public ThreadPool(int queueSize)
- Default constructor.
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.
ThreadPool
public ThreadPool(int corePoolSize,
int maximumPoolSize,
long keepAliveTime,
java.util.concurrent.TimeUnit unit)
- Size constructor.
an unbounded
LinkedBlockingQueue is used for the jobs queue;
ThreadPool
public ThreadPool(int corePoolSize,
int maximumPoolSize,
long keepAliveTime,
java.util.concurrent.TimeUnit unit,
java.util.concurrent.BlockingQueue<java.lang.Runnable> workQueue)
ThreadPool
public ThreadPool(int corePoolSize,
int maximumPoolSize,
long keepAliveTime,
java.util.concurrent.TimeUnit unit,
java.util.concurrent.BlockingQueue<java.lang.Runnable> workQueue,
java.util.concurrent.RejectedExecutionHandler handler)
ThreadPool
public ThreadPool(int corePoolSize,
int maximumPoolSize,
long keepAliveTime,
java.util.concurrent.TimeUnit unit,
java.util.concurrent.BlockingQueue<java.lang.Runnable> workQueue,
java.util.concurrent.ThreadFactory threadFactory,
java.util.concurrent.RejectedExecutionHandler handler)
ThreadPool
public ThreadPool(int corePoolSize,
int maximumPoolSize,
long keepAliveTime,
java.util.concurrent.TimeUnit unit,
java.util.concurrent.BlockingQueue<java.lang.Runnable> workQueue,
java.util.concurrent.ThreadFactory threadFactory)
dispatch
public boolean dispatch(java.lang.Runnable job)
- Specified by:
dispatch in interface ThreadPool
getIdleThreads
public int getIdleThreads()
- Specified by:
getIdleThreads in interface ThreadPool
getThreads
public int getThreads()
- Specified by:
getThreads in interface ThreadPool
isLowOnThreads
public boolean isLowOnThreads()
- Specified by:
isLowOnThreads in interface ThreadPool
join
public void join()
throws java.lang.InterruptedException
- Specified by:
join in interface ThreadPool
- Throws:
java.lang.InterruptedException
isFailed
public boolean isFailed()
- Specified by:
isFailed in interface LifeCycle
isRunning
public boolean isRunning()
- Specified by:
isRunning in interface LifeCycle
isStarted
public boolean isStarted()
- Specified by:
isStarted in interface LifeCycle
isStarting
public boolean isStarting()
- Specified by:
isStarting in interface LifeCycle
isStopped
public boolean isStopped()
- Specified by:
isStopped in interface LifeCycle
isStopping
public boolean isStopping()
- Specified by:
isStopping in interface LifeCycle
start
public void start()
throws java.lang.Exception
- Specified by:
start in interface LifeCycle
- Throws:
java.lang.Exception
stop
public void stop()
throws java.lang.Exception
- Specified by:
stop in interface LifeCycle
- Throws:
java.lang.Exception
addLifeCycleListener
public void addLifeCycleListener(LifeCycle.Listener listener)
- Specified by:
addLifeCycleListener in interface LifeCycle
removeLifeCycleListener
public void removeLifeCycleListener(LifeCycle.Listener listener)
- Specified by:
removeLifeCycleListener in interface LifeCycle
Copyright © 1995-2010 Mort Bay Consulting. All Rights Reserved.