Package com.illumon.util
Class ExpandingThreadPoolExecutorFactory
java.lang.Object
com.illumon.util.ExpandingThreadPoolExecutorFactory
public class ExpandingThreadPoolExecutorFactory extends Object
Creates a ThreadPoolExecutor which can then be used to submit or execute tasks. This is intended for cases where a relatively small number
of threads can handle most circumstances, but occasional abnormal events may exceed expectations. The executor has the following characteristics:
- Starting core and maximum thread pool sizes defined at creation time
- If an attempted execution exceeds the maximum number of allowed executor threads, a new Thread will be created dynamically instead of generating an exception
createThreadPoolExecutor(com.fishlib.io.logger.Logger, int, int, java.lang.String, java.lang.String, java.lang.String)
.-
Method Summary
Modifier and Type Method Description static ThreadPoolExecutor
createThreadPoolExecutor(com.fishlib.io.logger.Logger log, int corePoolSize, int keepAliveMinutes, String executorName, String poolThreadNamePrefix, String dynamicThreadNamePrefix)
Create aThreadPoolExecutor
with the characteristics defined inExpandingThreadPoolExecutorFactory
.
-
Method Details
-
createThreadPoolExecutor
public static ThreadPoolExecutor createThreadPoolExecutor(com.fishlib.io.logger.Logger log, int corePoolSize, int keepAliveMinutes, String executorName, String poolThreadNamePrefix, String dynamicThreadNamePrefix)Create aThreadPoolExecutor
with the characteristics defined inExpandingThreadPoolExecutorFactory
.- Parameters:
log
- a Logger to log messagescorePoolSize
- the core pool size (the executor will use this value for the initial core and maximum pool sizes)keepAliveMinutes
- the number of minutes to keep alive core threadsexecutorName
- the name of the executor, used when logging dynamic thread creationpoolThreadNamePrefix
- the prefix for thread pool threadsdynamicThreadNamePrefix
- the prefix for dynamic (overflow) threads created when the maximum number of pool threads is exceeded
-