Class GenericObjectPool<T>

    • Constructor Detail

      • GenericObjectPool

        public GenericObjectPool​(java.util.function.Supplier<T> supplier,
                                 int maxPoolSize)
        Constructs a new pool
        Parameters:
        supplier - used to create instances of the object to pool
        maxPoolSize - maximum items to have in the pool
    • Method Detail

      • borrowObject

        public T borrowObject()
        Borrows an object from the pool.
        Returns:
        the borrowed object
      • returnObject

        public void returnObject​(T item)
        Returns an instance to the pool. By contract, obj must have been obtained using borrowObject()
        Parameters:
        item - the item to return to the pool