Class StrongPool<T>

All Implemented Interfaces:

public class StrongPool<T> extends Object implements IPool<T>
An object pool backed by strong references. Objects stored in this pool will not be garbage collected as they refer to themselves. The client is responsible for nulling all references to the pool instance when it is no longer needed so that the contained objects can be garbage collected.

If a long lived, memory managed pool is required use WeakPool.

  • Constructor Details

    • StrongPool

      public StrongPool()
  • Method Details

    • add

      public T add(T newObject)
      Description copied from interface: IPool
      Returns the first object from this pool which is equal to the given object. If the pool contains no such object then the object is added to the pool and returned. If the object is null, null is returned.
      Specified by:
      add in interface IPool<T>
      newObject - the object to add
      a shared object that is equal to the given object or null