线程池创建和管理的工具类
<dependency>
<groupId>io.github.forezp</groupId>
<artifactId>matrix-threadpool-starter</artifactId>
<version>1.2</version>
</dependency>
- threadpool.core.pool.size
- threadpool.maximum.pool.size
- threadpool.keep.alive.time
- threadpool.allow.core.thread.timeout
- threadpool.queue
- threadpool.queue.capacity
- threadpool.rejected.policy
具体怎么配见ThreadConstant类。
@Autowired
ThreadPoolFactory threadPoolFactory;
ThreadPoolExecutor threadPoolExecutor=threadPoolFactory.createDefaultPoolExecutor();
ThreadPoolExecutor threadPoolExecutor=threadPoolFactory.createThreadPoolExecutor("forezp");
ThreadParameter threadParameter =new ThreadParameter();
threadParameter.setThreadPoolCorePoolSize(12);
threadParameter.setThreadPoolKeepAliveTime(600000);
...
ThreadPoolExecutor threadPoolExecutor=threadPoolFactory.createThreadPoolExecutor("forezp",threadParameter);