submarine.util
Class ObjectPool
java.lang.Object
|
+--submarine.util.ObjectPool
- Direct Known Subclasses:
- ConnectionManager
- public abstract class ObjectPool
- extends java.lang.Object
Constructor Summary |
ObjectPool(int initialSize,
int maxSize)
|
ObjectPool(int initialSize,
int maxSize,
int maxExtend)
|
Method Summary |
java.util.List |
clean()
Notify all the waiting threads and returns all the pooled objects.
|
abstract java.lang.Object |
createNewObject()
|
void |
destroyObject(java.lang.Object obj)
|
java.lang.Object |
get()
|
protected java.util.List |
getList()
|
void |
init()
|
void |
print(java.io.PrintWriter pout)
|
void |
put(java.lang.Object o,
boolean keep)
|
Methods inherited from class java.lang.Object |
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait |
list
private java.util.List list
used
private java.util.List used
initialSize
private int initialSize
maxSize
private int maxSize
maxExtend
private int maxExtend
waitingThreadcount
private int waitingThreadcount
locked
private boolean locked
ObjectPool
public ObjectPool(int initialSize,
int maxSize)
ObjectPool
public ObjectPool(int initialSize,
int maxSize,
int maxExtend)
init
public void init()
getList
protected java.util.List getList()
- Returns:
- java.util.List
put
public void put(java.lang.Object o,
boolean keep)
- Parameters:
o
-
get
public java.lang.Object get()
throws java.lang.Exception
- Returns:
- Object
- Throws:
java.lang.Exception
-
print
public void print(java.io.PrintWriter pout)
- Parameters:
pout
-
clean
public java.util.List clean()
- Notify all the waiting threads and returns all the pooled objects.
After the call the pool is empty
createNewObject
public abstract java.lang.Object createNewObject()
throws java.lang.Exception
destroyObject
public void destroyObject(java.lang.Object obj)
throws java.lang.Exception