T
- The pooled type.public class Pool<T>
extends java.lang.Object
Constructor and Description |
---|
Pool(java.lang.Class<T> theClass,
int initialSize)
Constructs a pool with the given size
|
Modifier and Type | Method and Description |
---|---|
T |
get()
Returns an object from the pool, growing self if necessary (by initialSize).
|
void |
returnToPool(T theInstance)
Return an object to the pool.
|
public Pool(java.lang.Class<T> theClass, int initialSize)
theClass
- The Class pooled. Should always be T.class. Sorry we can't do this ourselves.initialSize
- The initial size of the pool. If you pass a value less than 1, we'll just use 1.public T get()
public void returnToPool(T theInstance)
theInstance
- The T to return to the pool.