|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.opengts.util.ThreadPool
public class ThreadPool
Thread pool manager
Field Summary | |
---|---|
static int |
STOP_NEVER
|
static int |
STOP_NOW
|
static int |
STOP_WAITING
|
Constructor Summary | |
---|---|
ThreadPool(java.lang.String name)
Constuctor |
|
ThreadPool(java.lang.String name,
int maxPoolSize)
Constructor |
|
ThreadPool(java.lang.String name,
int maxPoolSize,
int maxIdleSec,
int maxQueueSize)
Constructor |
|
ThreadPool(java.lang.String name,
RTKey propPfx_,
int maxPoolSize,
int maxIdleSec,
int maxQueueSize)
Constructor |
Method Summary | |
---|---|
protected void |
_removeThreadJob(org.opengts.util.ThreadPool.ThreadJob thread)
Removes the specified worker thread from the pool |
boolean |
equals(java.lang.Object other)
Returns true if this object is equal to other . |
int |
getActiveCount()
Gets the number of currently active jobs |
long |
getMaxIdleMS()
Gets the maximum number of milliseconds that a thread is allowed to remain idle before it self terminates. |
int |
getMaxPoolSize()
Gets the maximum size of this thread pool |
int |
getMaxQueueSize()
Gets the maximum allowed number of waiting jobs (in "jobQueue") |
java.lang.String |
getName()
Gets the name of the thread pool |
int |
getPoolSize()
Gets the current size of this thread pool |
int |
getQueueSize()
Gets the job queue size (jobs not yet processed) |
java.lang.ThreadGroup |
getThreadGroup()
Gets the thread group of the Threads in this pool |
static java.lang.StringBuffer |
GetThreadPoolState(java.lang.StringBuffer sb)
Gets the ThreadPool state |
static int |
GetTotalThreadCount()
Tell all active threads to stop |
static void |
main(java.lang.String[] argv)
Main entry point for testing/debugging |
static int |
PrintThreadCount()
Tell all active threads to stop |
boolean |
run(java.lang.Runnable job)
Adds a new job to the thread pool's queue |
void |
setMaxIdleMS(long maxIdleMS)
Sets the maximum number of milliseconds that a thread is allowed to remain idle before it self terminates. |
void |
setMaxIdleSec(int maxIdleSec)
Sets the maximum number of seconds that a thread is allowed to remain idle before it self-terminates. |
void |
setMaxIdleSec(RTKey propKeySec,
int dftMaxIdleSec)
Sets the maximum number of seconds that a thread is allowed to remain idle before it self-terminates. |
void |
setMaxPoolSize(int maxSize)
Sets the maximum size of this thread pool |
void |
setMaxPoolSize(RTKey propKey,
int dftMaxSize)
Sets the maximum size of this thread pool |
void |
setMaxQueueSize(int maxQSize)
Sets the maximum allowed number of waiting jobs (in "jobQueue") |
void |
setMaxQueueSize(RTKey propKey,
int dftMaxQSize)
Sets the maximum allowed number of waiting jobs (in "jobQueue") |
void |
stopThreads()
Stops all threads in this pool once queued jobs are complete |
void |
stopThreads(boolean stopNow)
Stops all threads in this pool once queued jobs are complete |
static void |
StopThreads(boolean stopNow)
Tell all active threads to stop |
java.lang.String |
toString()
Returns the name of the thread pool |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int STOP_WAITING
public static final int STOP_NEVER
public static final int STOP_NOW
Constructor Detail |
---|
public ThreadPool(java.lang.String name)
name
- The name of the thread poolpublic ThreadPool(java.lang.String name, int maxPoolSize)
name
- The name of the thread poolmaxPoolSize
- The maximum number of threads in the thread poolpublic ThreadPool(java.lang.String name, int maxPoolSize, int maxIdleSec, int maxQueueSize)
name
- The name of the thread poolmaxPoolSize
- The maximum number of threads in the thread poolmaxIdleSec
- The maximum number of seconds a thread is allowed to remain
idle before it self-terminates.maxQueueSize
- The maximum number of jobs allowed in queuepublic ThreadPool(java.lang.String name, RTKey propPfx_, int maxPoolSize, int maxIdleSec, int maxQueueSize)
name
- The name of the thread poolpropPfx_
- The property key prefix from which the default attributes
for this ThreadPool will be obtained.maxPoolSize
- The maximum number of threads in the thread pool ("maximumPoolSize")maxIdleSec
- The maximum number of seconds a thread is allowed to remain
idle before it self-terminates ("maximumIdleSeconds")maxQueueSize
- The maximum number of jobs allowed in queue ("maximumQueueSize")Method Detail |
---|
public static void StopThreads(boolean stopNow)
stopNow
- True to stop threads, even if jobs are still queued. False
to stop only after all jobs have been processed. (note that
jobs currently being processed will continue until they are
done).public static int GetTotalThreadCount()
public static int PrintThreadCount()
public static java.lang.StringBuffer GetThreadPoolState(java.lang.StringBuffer sb)
public java.lang.String getName()
public java.lang.String toString()
toString
in class java.lang.Object
public boolean equals(java.lang.Object other)
other
. This will
only return true if they are the same object
equals
in class java.lang.Object
other
- The object to check equality with
other
is the same objectpublic java.lang.ThreadGroup getThreadGroup()
public int getActiveCount()
public int getPoolSize()
public void setMaxPoolSize(int maxSize)
maxSize
- The maximum size of the thread poolpublic void setMaxPoolSize(RTKey propKey, int dftMaxSize)
propKey
- The property key name to use for looking up the overriding
value in the runtime configuration properties.dftMaxSize
- The maximum size of the thread poolpublic int getMaxPoolSize()
public void setMaxIdleSec(int maxIdleSec)
maxIdleSec
- The maximum number of idle secondspublic void setMaxIdleSec(RTKey propKeySec, int dftMaxIdleSec)
propKeySec
- The propery name from which the maximum number of idle
seconds will attempt to be retrieved.dftMaxIdleSec
- The default maximum number of idle seconds.public void setMaxIdleMS(long maxIdleMS)
maxIdleMS
- The maximum number of idle millisecondspublic long getMaxIdleMS()
public void setMaxQueueSize(int maxQSize)
maxQSize
- The maximum allowed number of waiting jobspublic void setMaxQueueSize(RTKey propKey, int dftMaxQSize)
propKey
- The property key name to use for looking up the overriding
value in the runtime configuration properties.dftMaxQSize
- The maximum allowed number of waiting jobspublic int getMaxQueueSize()
public boolean run(java.lang.Runnable job)
job
- The job to add to the queuepublic int getQueueSize()
public void stopThreads()
public void stopThreads(boolean stopNow)
stopNow
- True to stop threads, even if jobs are still queued. False
to stop only after all jobs have been processed. (note that
jobs currently being processed will continue until they are
done).protected void _removeThreadJob(org.opengts.util.ThreadPool.ThreadJob thread)
thread
- The thread to remove from the poolpublic static void main(java.lang.String[] argv)
argv
- Comand-line arguments
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |