|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.cometway.util.ThreadPool
public class ThreadPool
This class starts and stops a pool of PooledThreads.
| Field Summary | |
|---|---|
protected java.util.Vector |
allocatedThreads
|
protected int |
max_threads
|
protected int |
nextID
|
int |
num_threads
|
protected int |
priority
|
protected Queue |
queue
|
protected java.lang.Object |
queueChanged
|
protected boolean |
stopped
|
protected java.lang.String |
threadPoolName
|
| Constructor Summary | |
|---|---|
ThreadPool(int max_threads)
Starts a ThreadPool with the max thread limit to the specified number. |
|
ThreadPool(int max_threads,
int thread_priority)
Starts a ThreadPool with the max thread limit to the specified number and a priority setting for the PooledThreads. |
|
| Method Summary | |
|---|---|
protected void |
error(java.lang.String s,
java.lang.Exception e)
|
int |
freeThreads()
This returns the number of allocated PooledThreads that are free |
boolean |
getThread(KMethod method)
This method gets an unused PooledThread or creates one if the pool has not exceeded its limit and executes the KMethod passed in. |
boolean |
getThread(KMethod method,
java.lang.Object obj)
This method gets an unused PooledThread or creates one if the pool has not exceeded its limit and executes the KMethod passed in. |
boolean |
getThread(KMethod method,
java.lang.Object obj,
int timeout)
This method gets an unused PooledThread or creates one if the pool has not exceeded its limit and executes the KMethod passed in. |
boolean |
getThreadOrWait(KMethod method,
int timeout)
|
boolean |
getThreadOrWait(KMethod method,
java.lang.Object obj,
int timeout)
|
static void |
main(java.lang.String[] args)
|
protected PooledThread |
makePooledThread()
|
protected void |
releaseThread(PooledThread t)
|
protected void |
returnThread(PooledThread t)
|
void |
setName(java.lang.String name)
This method sets the Name of this ThreadPool. |
void |
stop()
This method stops the ThreadPool allows it to be garbage collected. |
int |
totalThreads()
This returns the total number of allocated PooledThreads. |
int |
usedThreads()
This returns the number of allocated PooledThreads that are active. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected Queue queue
protected java.util.Vector allocatedThreads
public int num_threads
protected int max_threads
protected java.lang.String threadPoolName
protected int nextID
protected int priority
protected java.lang.Object queueChanged
protected boolean stopped
| Constructor Detail |
|---|
public ThreadPool(int max_threads)
public ThreadPool(int max_threads,
int thread_priority)
| Method Detail |
|---|
public void stop()
public void setName(java.lang.String name)
public boolean getThread(KMethod method,
java.lang.Object obj,
int timeout)
method - This is the KMethod to execute on a PooledThreadobj - This is the obj used to wait for the PooledThread to finish.timeout - This is the number of milliseconds to wait for the PooledThread to finish.
public boolean getThread(KMethod method,
java.lang.Object obj)
method - This is the KMethod to execute on a PooledThreadobj - This is the obj used to wait for the PooledThread to finish.
public boolean getThread(KMethod method)
method - This is the KMethod to execute on a PooledThread
public boolean getThreadOrWait(KMethod method,
int timeout)
public boolean getThreadOrWait(KMethod method,
java.lang.Object obj,
int timeout)
public int totalThreads()
public int usedThreads()
public int freeThreads()
protected PooledThread makePooledThread()
throws java.lang.NullPointerException
java.lang.NullPointerExceptionprotected void returnThread(PooledThread t)
protected void releaseThread(PooledThread t)
protected void error(java.lang.String s,
java.lang.Exception e)
public static void main(java.lang.String[] args)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||