Class ThreadPool

  • All Implemented Interfaces:
    java.lang.AutoCloseable, org.apache.commons.pool.ObjectPool

    public class ThreadPool
    extends org.apache.commons.pool.impl.GenericObjectPool
    implements java.lang.AutoCloseable
    A pool of Threads. The threads from this pool are used to launch the tasks.
    • Nested Class Summary

      • Nested classes/interfaces inherited from class org.apache.commons.pool.impl.GenericObjectPool

        org.apache.commons.pool.impl.GenericObjectPool.Config
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int DEFAULT_MAX_THREADS  
      • Fields inherited from class org.apache.commons.pool.impl.GenericObjectPool

        DEFAULT_LIFO, DEFAULT_MAX_ACTIVE, DEFAULT_MAX_IDLE, DEFAULT_MAX_WAIT, DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS, DEFAULT_MIN_IDLE, DEFAULT_NUM_TESTS_PER_EVICTION_RUN, DEFAULT_SOFT_MIN_EVICTABLE_IDLE_TIME_MILLIS, DEFAULT_TEST_ON_BORROW, DEFAULT_TEST_ON_RETURN, DEFAULT_TEST_WHILE_IDLE, DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS, DEFAULT_WHEN_EXHAUSTED_ACTION, WHEN_EXHAUSTED_BLOCK, WHEN_EXHAUSTED_FAIL, WHEN_EXHAUSTED_GROW
    • Constructor Summary

      Constructors 
      Constructor Description
      ThreadPool​(java.lang.String tenantID, int poolsize)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.Object borrowObject()  
      PoolableThread borrowThread()  
      void close()  
      static ThreadPool getInstance()  
      void returnObject​(java.lang.Object thread)  
      void returnThread​(PoolableThread thread)  
      • Methods inherited from class org.apache.commons.pool.impl.GenericObjectPool

        addObject, clear, evict, getLifo, getMaxActive, getMaxIdle, getMaxWait, getMinEvictableIdleTimeMillis, getMinIdle, getNumActive, getNumIdle, getNumTestsPerEvictionRun, getSoftMinEvictableIdleTimeMillis, getTestOnBorrow, getTestOnReturn, getTestWhileIdle, getTimeBetweenEvictionRunsMillis, getWhenExhaustedAction, invalidateObject, setConfig, setFactory, setLifo, setMaxActive, setMaxIdle, setMaxWait, setMinEvictableIdleTimeMillis, setMinIdle, setNumTestsPerEvictionRun, setSoftMinEvictableIdleTimeMillis, setTestOnBorrow, setTestOnReturn, setTestWhileIdle, setTimeBetweenEvictionRunsMillis, setWhenExhaustedAction, startEvictor
      • Methods inherited from class org.apache.commons.pool.BaseObjectPool

        assertOpen, isClosed
      • Methods inherited from class java.lang.Object

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

      • ThreadPool

        public ThreadPool​(java.lang.String tenantID,
                          int poolsize)
    • Method Detail

      • getInstance

        public static ThreadPool getInstance()
      • borrowObject

        public final java.lang.Object borrowObject()
        Specified by:
        borrowObject in interface org.apache.commons.pool.ObjectPool
        Overrides:
        borrowObject in class org.apache.commons.pool.impl.GenericObjectPool
      • returnObject

        public final void returnObject​(java.lang.Object thread)
                                throws java.lang.Exception
        Specified by:
        returnObject in interface org.apache.commons.pool.ObjectPool
        Overrides:
        returnObject in class org.apache.commons.pool.impl.GenericObjectPool
        Throws:
        java.lang.Exception
      • returnThread

        public final void returnThread​(PoolableThread thread)
                                throws java.lang.Exception
        Throws:
        java.lang.Exception
      • close

        public void close()
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface org.apache.commons.pool.ObjectPool
        Overrides:
        close in class org.apache.commons.pool.impl.GenericObjectPool