| | |
| | | public ThreadPoolTaskExecutor threadPoolTaskExecutor() { |
| | | ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); |
| | | |
| | | executor.setCorePoolSize(20); // 核心线程数, 根据需求进行调整 |
| | | executor.setMaxPoolSize(30); // 最大线程数, 适当设置以避免资源耗尽 |
| | | executor.setQueueCapacity(100); // 队列容量, 适当限制以避免请求堆积 |
| | | executor.setCorePoolSize(50); // 核心线程数, 根据需求进行调整 |
| | | executor.setMaxPoolSize(100); // 最大线程数, 适当设置以避免资源耗尽 |
| | | executor.setQueueCapacity(150); // 队列容量, 适当限制以避免请求堆积 |
| | | executor.setKeepAliveSeconds(30); // 线程空闲时的存活时间为30秒,减少系统开销 |
| | | executor.setThreadNamePrefix("Thread-"); // 线程名称的前缀 |
| | | |