Class Pool.Impl<T>

java.lang.Object
com.sun.istack.Pool.Impl<T>
All Implemented Interfaces:
Pool<T>
Enclosing interface:
Pool<T>

public abstract static class Pool.Impl<T> extends Object 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.

  • Nested Class Summary

    Nested classes/interfaces inherited from interface com.sun.istack.Pool

    Pool.Impl<T>
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected abstract T
    Creates a new instance of object.
    final void
    Returns an object back to the pool.
    final T
    Gets a new object from the pool.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Impl

      public Impl()
  • Method Details

    • 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.