RISC JKU

at.jku.risc.stout.urau.util

Class Pool<T extends Poolable>



  • public class Pool<T extends Poolable>
    extends Object
    A pool of objects of a certain type. The pooled class has to implement the interface Poolable. This object pool can be used to recycle objects and avoid memory allocation / garbage collection.
    Author:
    Alexander Baumgartner
    • Method Detail

      • free

        public void free(T obj)
        Calls the method Poolable.cleanUp() to clean the object and returns it into this pool.
      • getPool

        public static <T extends PoolablePool<T> getPool(T sample)
        Returns a Pool for a certain type of objects. A new pool will be created if there is not jet a pool available for the requested type.
      • obtain

        public T obtain()
        Pulls an object out of this Pool or creates a new object if the pool is empty.
      • removePool

        public void removePool()
        Removes this pool and let the garbage collector do it's work.