Class Pool<PO extends IPooledObject>

java.lang.Object
zombie.util.Pool<PO>

public final class Pool<PO extends IPooledObject> extends Object
A thread-safe object pool. Useful for re-using memory without it falling into the garbage collector. Beware: Once an item has been allocated, it MUST be released at some point by calling its release() function. If not, the item's memory will never be recycled, and it will be considered a memory leak.
  • Constructor Details

  • Method Details

    • getMonitoringPoolCounter

      public PoolCounter getMonitoringPoolCounter()
    • setMonitoringPoolCounter

      public void setMonitoringPoolCounter(PoolCounter foundCounter)
    • getPoolStacks

      public ThreadLocal<Pool.PoolStacks> getPoolStacks()
    • getID

      public int getID()
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • alloc

      public PO alloc()
    • release

      public void release(IPooledObject item)
    • tryRelease

      public static <E> E tryRelease(E obj)
    • tryRelease

      public static <E extends IPooledObject> E tryRelease(E pooledObject)
    • tryRelease

      public static <E extends IPooledObject> E[] tryRelease(E[] objArray)