public class ObjectPool extends TimedEntry
| Modifier and Type | Class and Description |
|---|---|
static interface |
ObjectPool.InstanceCreator |
| Constructor and Description |
|---|
ObjectPool(ObjectPool.InstanceCreator creator)
Creates a new pool with no limit on the maximum number of pooled objects and an initial pool
size of
10. |
ObjectPool(ObjectPool.InstanceCreator creator,
int initialSize)
Creates a new pool with a maximum total number of pooled objects of
maxSize. |
| Modifier and Type | Method and Description |
|---|---|
java.lang.Object |
acquire() |
void |
dispose() |
void |
release(java.lang.Object o) |
protected void |
timedOut()
Runs what should be done at time out.
|
isDisabled, toStringpublic ObjectPool(ObjectPool.InstanceCreator creator)
10.creator - the instance creator for creating new pooled objectspublic ObjectPool(ObjectPool.InstanceCreator creator, int initialSize)
maxSize. The
pool will initially have a capacity of initialSize instances. New instances will
be created by the specified creator.creator - the instance creator for creating new pooled objectsinitialSize - the initial pool sizemaxSize - the maximum pool size; if -1, no limit on the pool size is imposedpublic java.lang.Object acquire()
public void release(java.lang.Object o)
protected void timedOut()
TimedEntrytimedOut in class TimedEntrypublic void dispose()