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, org.mortbay.component.LifeCycle, org.mortbay.thread.ThreadPool
public class ThreadPool
- extends java.util.concurrent.ThreadPoolExecutor
- implements org.mortbay.thread.ThreadPool, org.mortbay.component.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 org.mortbay.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 |
Nested classes/interfaces inherited from interface org.mortbay.component.LifeCycle |
org.mortbay.component.LifeCycle.Listener |
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 org.mortbay.thread.ThreadPool
getIdleThreads
public int getIdleThreads()
- Specified by:
getIdleThreads
in interface org.mortbay.thread.ThreadPool
getThreads
public int getThreads()
- Specified by:
getThreads
in interface org.mortbay.thread.ThreadPool
isLowOnThreads
public boolean isLowOnThreads()
- Specified by:
isLowOnThreads
in interface org.mortbay.thread.ThreadPool
join
public void join()
throws java.lang.InterruptedException
- Specified by:
join
in interface org.mortbay.thread.ThreadPool
- Throws:
java.lang.InterruptedException
isFailed
public boolean isFailed()
- Specified by:
isFailed
in interface org.mortbay.component.LifeCycle
isRunning
public boolean isRunning()
- Specified by:
isRunning
in interface org.mortbay.component.LifeCycle
isStarted
public boolean isStarted()
- Specified by:
isStarted
in interface org.mortbay.component.LifeCycle
isStarting
public boolean isStarting()
- Specified by:
isStarting
in interface org.mortbay.component.LifeCycle
isStopped
public boolean isStopped()
- Specified by:
isStopped
in interface org.mortbay.component.LifeCycle
isStopping
public boolean isStopping()
- Specified by:
isStopping
in interface org.mortbay.component.LifeCycle
start
public void start()
throws java.lang.Exception
- Specified by:
start
in interface org.mortbay.component.LifeCycle
- Throws:
java.lang.Exception
stop
public void stop()
throws java.lang.Exception
- Specified by:
stop
in interface org.mortbay.component.LifeCycle
- Throws:
java.lang.Exception
addLifeCycleListener
public void addLifeCycleListener(org.mortbay.component.LifeCycle.Listener listener)
- Specified by:
addLifeCycleListener
in interface org.mortbay.component.LifeCycle
removeLifeCycleListener
public void removeLifeCycleListener(org.mortbay.component.LifeCycle.Listener listener)
- Specified by:
removeLifeCycleListener
in interface org.mortbay.component.LifeCycle
Copyright © 2009 Mortbay Consulting Pty. Ltd. All Rights Reserved.