Details
-
Bug
-
Status: Closed
-
Trivial
-
Resolution: Fixed
-
0.98.0
-
None
-
None
-
Reviewed
Description
/**
- 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.
*/
public static ThreadPoolExecutor getBoundedCachedThreadPool(
int maxCachedThread, long timeout, TimeUnit unit,
ThreadFactory threadFactory) { ThreadPoolExecutor boundedCachedThreadPool = new ThreadPoolExecutor(maxCachedThread, maxCachedThread, timeout, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>(), threadFactory); // allow the core pool threads timeout and terminate boundedCachedThreadPool.allowCoreThreadTimeOut(true); return boundedCachedThreadPool; }