|
||||||||||
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. |
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 |
getLowThreads()
|
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. |
boolean |
isLowOnThreads()
|
void |
join()
Blocks until the thread pool is stopped . |
protected BoundedThreadPool.PoolThread |
newThread(Runnable job)
|
void |
setDaemon(boolean daemon)
Delegated to the named or anonymous Pool. |
void |
setLowThreads(int lowThreads)
|
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, isStopped, isStopping, start, stop |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public BoundedThreadPool()
Method Detail |
---|
public boolean dispatch(Runnable job)
dispatch
in interface ThreadPool
public int getIdleThreads()
getIdleThreads
in interface ThreadPool
getThreads()
public int getLowThreads()
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 boolean isLowOnThreads()
isLowOnThreads
in interface ThreadPool
public void join() throws InterruptedException
ThreadPool
stopped
.
join
in interface ThreadPool
InterruptedException
public void setDaemon(boolean daemon)
public void setLowThreads(int lowThreads)
lowThreads
- low resource threads threshholdpublic 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 BoundedThreadPool.PoolThread newThread(Runnable job)
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 |