| | |
| | | @Configuration |
| | | public class ThreadPoolConfig { |
| | | |
| | | private int corePoolSize = 50; |
| | | private int corePoolSize = 5; |
| | | |
| | | private int maxPoolSize = 200; |
| | | private int maxPoolSize = 20; |
| | | |
| | | private int queueCapacity = 1000; |
| | | private int queueCapacity = 100; |
| | | |
| | | private int keepAliveSeconds = 300; |
| | | private int keepAliveSeconds = 60; |
| | | |
| | | @Bean(name = "threadPoolTaskExecutor") |
| | | public ThreadPoolTaskExecutor threadPoolTaskExecutor() { |
| | | ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); |
| | |
| | | executor.setCorePoolSize(corePoolSize); |
| | | executor.setQueueCapacity(queueCapacity); |
| | | executor.setKeepAliveSeconds(keepAliveSeconds); |
| | | //线程前缀名称 |
| | | executor.setThreadNamePrefix("thread-pool-%d"); |
| | | |
| | | executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy()); |
| | | return executor; |