|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.mortbay.component.AbstractLifeCycle org.mortbay.thread.BoundedThreadPool
public class BoundedThreadPool
A pool of threads.
Avoids the expense of thread creation by pooling threads after their run methods exit for reuse.
If the maximum pool size is reached, jobs wait for a free thread. By default there is no maximum pool size. Idle threads timeout and terminate until the minimum number of threads are running.
Nested Class Summary | |
---|---|
class |
BoundedThreadPool.PoolThread
Pool Thread class. |
Field Summary | |
---|---|
private static int |
__id
|
private List |
_blocked
|
private int |
_blockMs
|
private boolean |
_daemon
|
private int |
_id
|
private List |
_idle
|
private String |
_joinLock
|
private String |
_lock
|
private int |
_maxIdleTimeMs
|
private int |
_maxThreads
|
private int |
_minThreads
|
private String |
_name
|
(package private) int |
_priority
|
private Set |
_threads
|
private boolean |
_warned
|
private static long |
serialVersionUID
|
Constructor Summary | |
---|---|
BoundedThreadPool()
|
Method Summary | |
---|---|
boolean |
dispatch(Runnable job)
Run job. |
protected void |
doStart()
|
protected void |
doStop()
Stop the BoundedThreadPool. |
int |
getIdleThreads()
Get the number of idle threads in the pool. |
int |
getMaxIdleTimeMs()
Get the maximum thread idle time. |
int |
getMaxThreads()
Set the maximum number of threads. |
int |
getMinThreads()
Get the minimum number of threads. |
String |
getName()
|
int |
getThreads()
Get the number of threads in the pool. |
int |
getThreadsPriority()
Get the priority of the pool threads. |
boolean |
isDaemon()
Delegated to the named or anonymous Pool. |
void |
join()
|
protected void |
newThread()
|
void |
setDaemon(boolean daemon)
Delegated to the named or anonymous Pool. |
void |
setMaxIdleTimeMs(int maxIdleTimeMs)
Set the maximum thread idle time. |
void |
setMaxThreads(int maxThreads)
Set the maximum number of threads. |
void |
setMinThreads(int minThreads)
Set the minimum number of threads. |
void |
setName(String name)
|
void |
setThreadsPriority(int priority)
Set the priority of the pool threads. |
protected void |
stopJob(Thread thread,
Object job)
Stop a Job. |
Methods inherited from class org.mortbay.component.AbstractLifeCycle |
---|
isFailed, isRunning, isStarted, isStarting, isStopping, start, stop |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.mortbay.component.LifeCycle |
---|
isFailed, isRunning, isStarted, isStarting, isStopping, start, stop |
Field Detail |
---|
private static final long serialVersionUID
private static int __id
private transient List _blocked
private int _blockMs
private boolean _daemon
private transient int _id
private final String _lock
private final String _joinLock
private int _maxIdleTimeMs
private int _maxThreads
private int _minThreads
private String _name
int _priority
private Set _threads
private List _idle
private boolean _warned
Constructor Detail |
---|
public BoundedThreadPool()
Method Detail |
---|
public int getIdleThreads()
getIdleThreads
in interface ThreadPool
getThreads()
public int getMaxIdleTimeMs()
setMaxIdleTimeMs(int)
public int getMaxThreads()
setMaxThreads(int)
public int getMinThreads()
setMinThreads(int)
public String getName()
public int getThreads()
getThreads
in interface ThreadPool
getIdleThreads()
public int getThreadsPriority()
public boolean isDaemon()
public void join() throws InterruptedException
join
in interface ThreadPool
InterruptedException
protected void newThread()
public boolean dispatch(Runnable job)
dispatch
in interface ThreadPool
public void setDaemon(boolean daemon)
public void setMaxIdleTimeMs(int maxIdleTimeMs)
maxIdleTimeMs
- Max idle time in ms.getMaxIdleTimeMs()
public void setMaxThreads(int maxThreads)
maxThreads
- maximum number of threads.getMaxThreads()
public void setMinThreads(int minThreads)
minThreads
- minimum number of threadsgetMinThreads()
public void setName(String name)
name
- Name of the BoundedThreadPool to use when naming Threads.public void setThreadsPriority(int priority)
priority
- the new thread priority.protected void doStart() throws Exception
doStart
in class AbstractLifeCycle
Exception
protected void doStop() throws Exception
doStop
in class AbstractLifeCycle
Exception
protected void stopJob(Thread thread, Object job)
thread
- The thread allocated to the job, or null if no thread allocated.job
- The job object passed to run.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |