Package generic.cache

Class CachingPool<T>

  • Type Parameters:
    T - the type of object to pool

    public class CachingPool<T>
    extends java.lang.Object
    A thread-safe pool class that knows how to create instances as needed. When clients are done with the pooled item they then call release(Object).
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void dispose()  
      T get()
      Returns a cached or new CachingPool
      void release​(T t)  
      void setCleanupTimeout​(long timeout)
      Sets the time to wait for released items to be automatically disposed.
      • Methods inherited from class java.lang.Object

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

    • Method Detail

      • setCleanupTimeout

        public void setCleanupTimeout​(long timeout)
        Sets the time to wait for released items to be automatically disposed. The default is TIMEOUT.
        Parameters:
        timeout - the new timeout.
      • get

        public T get()
              throws java.lang.Exception
        Returns a cached or new CachingPool
        Returns:
        a cached or new CachingPool
        Throws:
        java.lang.Exception - if there is a problem instantiating a new instance
      • release

        public void release​(T t)
      • dispose

        public void dispose()