| | |
| | | @Configuration |
| | | public class ThreadPoolConfig { |
| | | //核心线程池大小 |
| | | private int corePoolSize=50; |
| | | private int corePoolSize=10; |
| | | //最大可创建的线程数 |
| | | private int maxPoolSize=200; |
| | | private int maxPoolSize=500; |
| | | //队列最大长度 |
| | | private int queueCapacity=1000; |
| | | //线程池维护非线程允许的空闲时间 |
| | | private int keepAliveSeconds=300; |
| | | private int keepAliveSeconds=30; |
| | | |
| | | @Bean(name = "threadPoolTaskExecutor") |
| | | public ThreadPoolTaskExecutor threadPoolTaskExecutor(){ |
| | |
| | | executor.setKeepAliveSeconds(keepAliveSeconds); |
| | | // 线程池对拒绝任务(无线程可用)的处理策略 |
| | | executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy()); |
| | | executor.initialize(); |
| | | return executor; |
| | | } |
| | | |