Interface Pool<E>

Type Parameters:
E - The type of object managed by this pool.
All Known Implementing Classes:
LinkedPool, Unpool

public interface Pool<E>
The Pool interface allows for pooling of objects.

Objects can be obtained from a pool and can later be resupplied to the pool to enable the pool to provide that object again in the future, which can reduce the overhead associated with object creation and garbage collection.

Since:
1.8
  • Method Summary

    Modifier and Type
    Method
    Description
    Claims an instance of Pooled from the pool.
  • Method Details

    • claim

      Pooled<E> claim()
      Claims an instance of Pooled from the pool.

      When done with the object, it may be returned to the pool using either the Pooled.free() method or the Pooled.close() method. Do not call both, that would be a double-free.

      It is valid to not return ("steal") a claimed object to the pool. That prevents the pool from providing that object ever again.

      Returns:
      A Pooled instance containing an object of type E.