Class StringBuilderPool

java.lang.Object
com.tenio.common.logger.pool.StringBuilderPool
All Implemented Interfaces:
ElementPool<StringBuilder>

@ThreadSafe public final class StringBuilderPool extends Object implements ElementPool<StringBuilder>
The object pool mechanism for StringBuilder.
  • Method Details

    • getInstance

      public static StringBuilderPool getInstance()
      Preventing Singleton object instantiation from outside creates multiple instance if two thread access this method simultaneously.
      Returns:
      the instance of this class
    • get

      public StringBuilder get()
      Description copied from interface: ElementPool
      Retrieves an element in the current pool.
      Specified by:
      get in interface ElementPool<StringBuilder>
      Returns:
      an element in the pool
    • repay

      public void repay(StringBuilder element)
      Description copied from interface: ElementPool
      When you finished using an element, repay (free) it for the reusing.
      Specified by:
      repay in interface ElementPool<StringBuilder>
      Parameters:
      element - the finished using element
    • cleanup

      public void cleanup()
      Description copied from interface: ElementPool
      Clean up, after that all array elements will be set to null.
      Specified by:
      cleanup in interface ElementPool<StringBuilder>
    • getPoolSize

      public int getPoolSize()
      Description copied from interface: ElementPool
      Retrieves the pool size.
      Specified by:
      getPoolSize in interface ElementPool<StringBuilder>
      Returns:
      the total number of element or -1 if any exceptions caused
    • getAvailableSlot

      public int getAvailableSlot()
      Description copied from interface: ElementPool
      Retrieves the current available slots.
      Specified by:
      getAvailableSlot in interface ElementPool<StringBuilder>
      Returns:
      the number of available slots in the pool