|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.sapia.ubik.net.Pool
org.sapia.ubik.net.ThreadPool
public abstract class ThreadPool
A pool of PooledThread instances. Inheriting classes
must implement the newThread() method, which must return
an application-specific PooledThread instance.
Applications must use the pool in the following manner:
PooledThread thread = (PooledThread)threadPool.acquire(); thread.exec(someData);Upon the
exec() method being called, the thread
immediately:
doExec method;
Thus, applications need not be concerned about returning the passed in thread to the pool.
PooledThread,
PooledThread.doExec(Object)| Field Summary |
|---|
| Fields inherited from class org.sapia.ubik.net.Pool |
|---|
_currentCount, _lastUsageTime, _maxSize, _objects, NO_MAX, NO_TIME_OUT |
| Constructor Summary | |
|---|---|
protected |
ThreadPool(java.lang.String name,
boolean daemon)
Creates a thread pool. |
protected |
ThreadPool(java.lang.String name,
boolean daemon,
int maxSize)
Creates a thread pool. |
| Method Summary | |
|---|---|
void |
disableStats()
Disables statistics |
protected java.lang.Object |
doNewObject()
This template method should be overridden by inheriting classes to provide object instances that will be pooled. |
void |
enabledStats()
Enables statistics |
Statistic |
getDurationStat()
|
Statistic |
getRpsStat()
|
int |
getThreadCount()
|
protected abstract PooledThread |
newThread()
This method must be overridden by inheriting classes; the returned thread must not be started by this method; the pool implements this behavior. |
protected java.lang.Object |
onAcquire(java.lang.Object o)
|
protected void |
onRelease(java.lang.Object o)
|
void |
shutdown()
Cleanly shuts down this instance. |
void |
shutdown(long timeout)
Cleanly shuts down this instance; internally busy threads are interrupted - currently executing threads finish their task before termination. |
| Methods inherited from class org.sapia.ubik.net.Pool |
|---|
acquire, acquire, acquireCreate, cleanup, fill, getCreatedCount, getLastUsageTime, release, shrinkTo, size |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
protected ThreadPool(java.lang.String name,
boolean daemon,
int maxSize)
name - the name of the threads that will be created (to distinguish
among the different threads, a counter is appended to the name for
each thread).daemon - if true, the threads created by this pool will
be set as daemon.maxSize - the maximum number of threads that this pool creates.
protected ThreadPool(java.lang.String name,
boolean daemon)
name - the name of the threads that will be created (to distinguish
among the different threads, a counter is appended to the name for
each thread).daemon - if true, the threads created by this pool will
be set as daemon.| Method Detail |
|---|
protected java.lang.Object onAcquire(java.lang.Object o)
throws java.lang.Exception,
java.lang.IllegalStateException
onAcquire in class Pooljava.lang.IllegalStateException - if this instance is shutting down or is shut down.
java.lang.ExceptionPool.onAcquire(Object)protected void onRelease(java.lang.Object o)
onRelease in class PoolPool.onRelease(Object)public Statistic getRpsStat()
public Statistic getDurationStat()
public void enabledStats()
public void disableStats()
public void shutdown()
shutdown(long)public int getThreadCount()
public void shutdown(long timeout)
This method waits that all threads are finished before it returns, OR until the given timeout is reached.
timeout - a shutdown timeout - this method will return
when this timeout is reached, even if some threads are still
executing.
protected final java.lang.Object doNewObject()
throws java.lang.Exception
Pool
doNewObject in class PoolObject to pool.
java.lang.Exception - if an error occurs while creating the object to be
returned.Pool.doNewObject()
protected abstract PooledThread newThread()
throws java.lang.Exception
PooledThread instance.
java.lang.Exception
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||