com.sun.istack
Class Pool.Impl<T>
java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractQueue<E>
java.util.concurrent.ConcurrentLinkedQueue<T>
com.sun.istack.Pool.Impl<T>
- All Implemented Interfaces:
- Pool<T>, java.io.Serializable, java.lang.Iterable<T>, java.util.Collection<T>, java.util.Queue<T>
- Enclosing interface:
- Pool<T>
public abstract static class Pool.Impl<T>
- extends java.util.concurrent.ConcurrentLinkedQueue<T>
- implements Pool<T>
Default implementation that uses ConcurrentLinkedQueue
as the data store.
Note for Implementors
Don't rely on the fact that this class extends from ConcurrentLinkedQueue
.
- See Also:
- Serialized Form
Nested classes/interfaces inherited from interface com.sun.istack.Pool |
Pool.Impl<T> |
Method Summary |
protected abstract T |
create()
Creates a new instance of object. |
void |
recycle(T t)
Returns an object back to the pool. |
T |
take()
Gets a new object from the pool. |
Methods inherited from class java.util.concurrent.ConcurrentLinkedQueue |
add, contains, isEmpty, iterator, offer, peek, poll, remove, size, toArray, toArray |
Methods inherited from class java.util.AbstractQueue |
addAll, clear, element, remove |
Methods inherited from class java.util.AbstractCollection |
containsAll, removeAll, retainAll, toString |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.util.Queue |
element, remove |
Methods inherited from interface java.util.Collection |
addAll, clear, containsAll, equals, hashCode, removeAll, retainAll |
Pool.Impl
public Pool.Impl()
take
@NotNull
public final T take()
- Gets a new object from the pool.
If no object is available in the pool, this method creates a new one.
- Specified by:
take
in interface Pool<T>
- Returns:
- always non-null.
recycle
public final void recycle(T t)
- Returns an object back to the pool.
- Specified by:
recycle
in interface Pool<T>
create
@NotNull
protected abstract T create()
- Creates a new instance of object.
This method is used when someone wants to
take
an object from an empty pool.
Also note that multiple threads may call this method
concurrently.