Interface ObjectPool<T>

Type Parameters:
T - Type of element pooled in this pool.
All Superinterfaces:
AutoCloseable, Closeable
All Known Implementing Classes:
BaseObjectPool, GenericObjectPool, SoftReferenceObjectPool

public interface ObjectPool<T> extends Closeable
A pooling simple interface.

Example of use:

 Object obj = null;

 try {
     obj = pool.borrowObject();
     try {
         //...use the object...
     } catch (Exception e) {
         // invalidate the object
         // do not return the object to the pool twice
         obj = null;
     } finally {
         // make sure the object is returned to the pool
         if (null != obj) {
 } catch(Exception e) {
       // failed to borrow an object

See BaseObjectPool for a simple base implementation.

See Also: