|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.w3c.util.ThreadCache
public class ThreadCache
Field Summary | |
---|---|
protected int |
cachesize
Number of cached threads. |
protected org.w3c.util.CachedThread |
freelist
List of free threads. |
protected org.w3c.util.CachedThread |
freetail
|
protected java.lang.ThreadGroup |
group
The thread group for this thread cache. |
protected boolean |
growasneeded
Should we queue thread requests, rather then creating new threads. |
protected int |
idlethreads
Number of idle threads to always maintain alive. |
protected int |
idletimeout
The idle timeout, for a thread to wait before being killed. |
protected boolean |
inited
Has this thread cache been initialized ? |
protected int |
threadcount
Number of created threads. |
protected int |
threadid
Uniq thread identifier within this ThreadCache instance. |
protected int |
threadpriority
Cached thread priority. |
protected int |
usedthreads
Number of used threads |
Constructor Summary | |
---|---|
ThreadCache(java.lang.String name)
Create a thread cache, after creating a new thread group. |
|
ThreadCache(java.lang.ThreadGroup group)
Create a thread cache, whose threads are to be children of the group. |
|
ThreadCache(java.lang.ThreadGroup parent,
java.lang.String name)
Create a thread cache, after creating a new thread group. |
Method Summary | |
---|---|
protected org.w3c.util.CachedThread |
allocateThread(boolean waitp)
Allocate a new thread, as requested. |
boolean |
getThread(java.lang.Runnable runnable,
boolean waitp)
Request a thread to run on the given object. |
java.lang.ThreadGroup |
getThreadGroup()
Get the ThreadGroup managed by this ThreadCache instance. |
int |
getThreadPriority()
Get the cached thread normal priority. |
void |
initialize()
Initialize the given thread cache. |
void |
setCachesize(int cachesize)
Set the thread cache size. |
void |
setCachesize(int cachesize,
boolean update)
Set the thread cache size. |
void |
setGrowAsNeeded(boolean onoff)
Enable/disable the thread cache to grow as needed. |
void |
setIdleTimeout(int idletimeout)
Set the idle timeout. |
void |
setThreadPriority(int priority)
Set all the cached threads priority. |
void |
waitForCompletion()
Wait until all the threads have finished their duty |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected boolean inited
protected java.lang.ThreadGroup group
protected int cachesize
protected int threadcount
protected int threadid
protected int idlethreads
protected boolean growasneeded
protected int usedthreads
protected org.w3c.util.CachedThread freelist
protected org.w3c.util.CachedThread freetail
protected int idletimeout
protected int threadpriority
Constructor Detail |
---|
public ThreadCache(java.lang.ThreadGroup group)
group
- The thread group to which this thread cache is bound.nstart
- Number of thread to create in advance.public ThreadCache(java.lang.String name)
name
- The name of the thread group to create.public ThreadCache(java.lang.ThreadGroup parent, java.lang.String name)
parent
- The parent of the thread group to create.name
- The name of the thread group.Method Detail |
---|
protected org.w3c.util.CachedThread allocateThread(boolean waitp)
waitp
- Should we wait until a thread is available ?
waitp
is
false.public void setCachesize(int cachesize, boolean update)
cachesize
- The new thread cache size.update
- If true also update the number of
threads to maintain idle.public void setCachesize(int cachesize)
cachesize
- The new thread cache size.public void setGrowAsNeeded(boolean onoff)
onoff
- The toggle.public void setThreadPriority(int priority)
priority
- The new cachewd threads priority.public int getThreadPriority()
public void setIdleTimeout(int idletimeout)
idletimeout
- The new idle timeout.public boolean getThread(java.lang.Runnable runnable, boolean waitp)
runnable
- The object to run with the allocated thread.waitp
- If true wait until a free thread is
available, otherwise, return false.
public java.lang.ThreadGroup getThreadGroup()
public void waitForCompletion()
public void initialize()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |