Class ObjectPool<T>

    • Constructor Detail

      • ObjectPool

        public ObjectPool()
    • Method Detail

      • borrowObject

        public T borrowObject()
        Gets the next free object from the pool. If the pool doesn't contain any objects, a new object will be created and given to the caller of this method back.
        Returns:
        T borrowed object
      • returnObject

        public void returnObject(T object)
        Returns object back to the pool.
        Parameters:
        object - object to be returned
      • shutdown

        public void shutdown()
        Shutdown this pool.
      • start

        public void start()
        Description copied from interface: SchedulerLifecycle
        Allows the Scheduler instance to start threads and accept tasks on them.

        Implementations should make sure the call is idempotent and threadsafe.

      • createObject

        protected abstract T createObject()
        Creates a new object.
        Returns:
        T new object