|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sourceforge.groboutils.util.thread.v1.ThreadPool
A pool of QueueThread instances, each containing an instance of an ObjectListener implemented class. The Class to be the listener is passed into the constructor. Requirements for the Class are: 1. it implements QueueThread.ObjectListener, 2. it has a public constructor without any parameters.
The pool handles menial tasks such as:
The pool gets much of its functionality by sharing a single SynchQueue between all of its threads.
Constructor Summary | |
ThreadPool(java.lang.Class objectListenerClass)
Default constructor |
|
ThreadPool(java.lang.Class objectListenerClass,
int maxThreads)
|
|
ThreadPool(java.lang.Class objectListenerClass,
java.lang.Object initData)
|
|
ThreadPool(java.lang.Class objectListenerClass,
java.lang.Object initData,
int maxThreads)
|
|
ThreadPool(java.lang.Class objectListenerClass,
java.lang.Object initData,
int startingThreadCount,
int maxThreads)
|
Method Summary | |
protected QueueThread |
addNewThread()
If there are not enough threads, then add one into the internal array, start the thread, and return the created thread. |
void |
addObject(java.lang.Object o)
Adds the given object into the shared queue, so that the next available thread will process it. |
protected void |
checkThreshold()
Checks if the depth on the shared queue is too deep (beyond the threshold), and if so, creates a new thread to help deal with the situation. |
protected IObjectListener |
createObjectListenerInstance()
Create an instance of the basic object listener class, as given in the constructor. |
int |
getMaximumThreadCount()
|
int |
getObjectDepth()
|
int |
getThreadCount()
|
void |
resumeThreads()
Resumes all threads. |
void |
setDepthThreshold(int threshold)
|
void |
setMaximumThreadCount(int max)
|
void |
stopThreads()
Stops all threads. |
void |
suspendThreads()
Suspends all threads. |
void |
waitForThreadsToFinish()
Waits for all expecting objects in the queue to be processed, and for each thread to finish processing an object. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public ThreadPool(java.lang.Class objectListenerClass)
public ThreadPool(java.lang.Class objectListenerClass, int maxThreads)
public ThreadPool(java.lang.Class objectListenerClass, java.lang.Object initData)
initData
- if the given objectListenerClass is an instance
of ThreadObjectListener, then the initData will be passed
into the initialize( Object ) method.public ThreadPool(java.lang.Class objectListenerClass, java.lang.Object initData, int maxThreads)
public ThreadPool(java.lang.Class objectListenerClass, java.lang.Object initData, int startingThreadCount, int maxThreads)
Method Detail |
public void setDepthThreshold(int threshold)
public int getObjectDepth()
public void addObject(java.lang.Object o)
public int getThreadCount()
public int getMaximumThreadCount()
public void setMaximumThreadCount(int max)
public void waitForThreadsToFinish()
public void stopThreads()
public void suspendThreads()
public void resumeThreads()
protected QueueThread addNewThread()
protected void checkThreshold()
protected IObjectListener createObjectListenerInstance()
java.lang.IllegalStateException
- thrown if there is an error
creating a new instance of the class.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |