public static ThreadPoolExecutor getShrinkingExecutor ( int maxThreadCount , int threadTimeout , String poolName ) { return new ThreadPoolExecutor ( 0 , maxThreadCount , threadTimeout , TimeUnit . MILLISECONDS , new LinkedBlockingQueue <> ( ) , getThreadFactory ( poolName ) , new CallerRuns ( ) ) ; // Caller runs only occurs after shutdown, as queue size is unbounded. }
Operates like Executors . cachedThreadPool but with a custom thread timeout and pool name .