public abstract class WeakObjectPool<T,E extends java.lang.Throwable>
extends java.lang.Object
getObject() and (repool(Object). Objects are held through
weak references so even objects that are not repooled are subject to garbage collection.
Subclasses must implement the abstract createObject().
Internally, the pool is stored in a java.util.concurrent.LinkedBlockingDeque instance.
| Modifier | Constructor and Description |
|---|---|
protected |
WeakObjectPool()
The lone constructor.
|
| Modifier and Type | Method and Description |
|---|---|
protected abstract T |
createObject()
Called whenever a new pool object is desired; subclasses must implement.
|
T |
getObject()
Subclasses can subclass to return a more specific type.
|
boolean |
repool(T obj)
Adds the given object to the pool, provided that the object
was created by this pool.
|
protected abstract T createObject() throws E extends java.lang.Throwable
parameterizable - Throwable's subclassE extends java.lang.Throwablepublic T getObject() throws E extends java.lang.Throwable
EE extends java.lang.Throwablepublic boolean repool(T obj)
obj - the object to return to the poolCopyright © 2007–2023. All rights reserved.