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
         pool.invalidateObject(obj);
         // do not return the object to the pool twice
         obj = null;
     } finally {
         // make sure the object is returned to the pool
         if (null != obj) {
             pool.returnObject(obj);
        }
     }
 } catch(Exception e) {
       // failed to borrow an object
 }

See BaseObjectPool for a simple base implementation.

Since:
2.0
See Also: