|
Voyager ORB | |||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
com.objectspace.lib.thread.ThreadPool
A ThreadPool allows threads to be reused.
Each thread pool contains an internal cache which is set to the initial capacity. When a thread is requested using assignThreadTo(), a new thread is created only if one cannot be reactivated from the cache. When a thread that was allocated using assignThreadTo() completes, it is deactivated and added to the cache.
If a thread is returned to the pool and there are no waiting requests, it is placed in a cache.
Constructor Summary | |
ThreadPool()
Construct a thread pool with 0 initial threads, a creation rate of 1, and no specified maxCapacity. |
|
ThreadPool(java.lang.ThreadGroup threadGroup)
Construct a thread pool with 0 initial threads, a creation rate of 1, and no specified maxCapacity. |
|
ThreadPool(java.lang.ThreadGroup threadGroup,
int initialCapacity,
int creationRate,
int maxCapacity)
Construct a thread pool with the specified parameters. |
Method Summary | |
void |
assignThreadTo(java.lang.Runnable runnable)
Assign a thread with no name and current priority to the runnable object and start it running immediately. |
void |
assignThreadTo(java.lang.Runnable runnable,
java.lang.String name)
Assign a thread with the specified name and priority to the runnable object and start it running immediately. |
void |
assignThreadTo(java.lang.Runnable runnable,
java.lang.String name,
int priority)
Assign a thread with the specified name and priority to the runnable object and start it running immediately. |
int |
getCreationRate()
Return the rate at which resources are created. |
int |
getFreeThreadCount()
Return the number of threads in the free pool. |
int |
getMaxIdleThreads()
Return the maximum number of threads I can cache. |
int |
getTotalThreadCount()
Return the total number of threads that are being managed by this thread pool. |
void |
setCreationRate(int creationRate)
Set the rate at which resources are created. |
void |
setMaxIdleThreads(int maxIdleThreads)
Set the maximum number of threads I can cache. |
Constructor Detail |
public ThreadPool()
public ThreadPool(java.lang.ThreadGroup threadGroup)
public ThreadPool(java.lang.ThreadGroup threadGroup, int initialCapacity, int creationRate, int maxCapacity)
Method Detail |
public int getTotalThreadCount()
public int getFreeThreadCount()
public void setMaxIdleThreads(int maxIdleThreads)
maxIdleThreads
- the maximum number of threads I can cache.public int getMaxIdleThreads()
public void setCreationRate(int creationRate)
public int getCreationRate()
public void assignThreadTo(java.lang.Runnable runnable, java.lang.String name, int priority)
runnable
- The object whose run() method will be executed.name
- The name to be given to the thread.priority
- The priority to be given to the thread.public void assignThreadTo(java.lang.Runnable runnable, java.lang.String name)
runnable
- The object whose run() method will be executed.name
- The name to be given to the thread.public void assignThreadTo(java.lang.Runnable runnable)
runnable
- The object whose run() method will be executed.
|
ObjectSpace Inc. | |||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |