Interface ObjectPool<O>

All Known Implementing Classes:
LandFillObjectPool

public interface ObjectPool<O>
An interface to get and give back objects that are intended to be long-lived and recycled, but where the location in the code for beginning to use the object is far from the location where we stop using it, e.g. across different threads. If the reuse is localized, then consider whether it may be simpler to leverage a ThreadLocal or a CloseableThreadLocal. The intent of having an interface is to experiment with different pooling strategies.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    dispose(O object)
    Return an object to the pool, indicating that it will no longer be used and can be recycled.
    get()
     
  • Method Details

    • get

      O get()
      Returns:
      an object, potentially from the pool, or potentially instantiating a new one if necessary.
    • dispose

      void dispose(O object)
      Return an object to the pool, indicating that it will no longer be used and can be recycled.
      Parameters:
      object - which is no longer used.