newCachedBoundedThreadPool
public static ExecutorService newCachedBoundedThreadPool(int corePoolSize,
int maximumPoolSize,
long keepAliveTime,
TimeUnit timeUnit,
ThreadFactory threadFactory)
Similar to Executors.newCachedThreadPool but allows a maximum pool size.
Cached thread pool are interesting in the sense that they can grow and shrink at will.
Default cachedThreadPool implementation does not allow to have a maximum capacity
- Parameters:
corePoolSize
- the number of threads to keep in the pool, even if they are idle
maximumPoolSize
- the maximum number of threads to allow in the pool
keepAliveTime
- when the number of threads is greater than the core, this is the maximum time that excess idle threads
will wait for new tasks before terminating.
timeUnit
- the time unit for the keepAliveTime
argument
threadFactory
- the factory to use when the executor
creates a new thread
- Returns:
- the newly created thread pool