|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectedu.jhu.tmaj.util.ObjectPool
public final class ObjectPool
A utility that manages a group of resources in a thread safe manner. Any resource that can be initialized and placed into this pool. When threads need to use them, they request a resource and this pool make sure that only one thread at a time will be able to use the resource.
| Nested Class Summary | |
|---|---|
static class |
ObjectPool.WaitTime
|
| Constructor Summary | |
|---|---|
ObjectPool()
Default constructor. |
|
| Method Summary | |
|---|---|
void |
addObject(java.lang.Object object)
Adds an element to the pool. |
int |
getAvailableCount()
Gets the number of unused objects in the pool. |
java.lang.Object |
getObject(ObjectPool.WaitTime waitTime)
Acquires an object from the pool. |
int |
getPoolSize()
Gets the total number of objects in the pool. |
void |
releaseObject(java.lang.Object object)
Returns the object to the pool. |
void |
removeAllObjects()
Removes all elements from the pool. |
void |
removeObject(java.lang.Object object)
Removes an element from the pool. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ObjectPool()
| Method Detail |
|---|
public void addObject(java.lang.Object object)
public void removeObject(java.lang.Object object)
public void removeAllObjects()
public java.lang.Object getObject(ObjectPool.WaitTime waitTime)
releaseObject to return the object, even in the
case of error conditions.
timeout - maximum time in milliseconds to wait for the object. 0 means wait forever *
public void releaseObject(java.lang.Object object)
public int getPoolSize()
public int getAvailableCount()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||