public static ThreadPoolExecutor getBoundedCachedThreadPool(int maxCachedThread, long timeout,
    TimeUnit unit, ThreadFactory threadFactory) {
    ThreadPoolExecutor boundedCachedThreadPool = new ThreadPoolExecutor(maxCachedThread,
      maxCachedThread, timeout, unit, new LinkedBlockingQueue<>(), threadFactory);
    // allow the core pool threads timeout and terminate
    boundedCachedThreadPool.allowCoreThreadTimeOut(true);
    return boundedCachedThreadPool;
  }
Create a new CachedThreadPool with a bounded number as the maximum thread size in the pool.
@param maxCachedThread the maximum thread could be created in the pool
@param timeout         the maximum time to wait
@param unit            the time unit of the timeout argument
@param threadFactory   the factory to use when creating new threads
@return threadPoolExecutor the cachedThreadPool with a bounded number as the maximum thread
        size in the pool.
hbase-common/src/main/java/org/apache/hadoop/hbase/util/Threads.java