1234567891011121314151617181920212223 |
- package com.lqkj.link.config;
- import org.springframework.context.annotation.Bean;
- import org.springframework.context.annotation.Configuration;
- import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
- import java.util.concurrent.Executor;
- @Configuration
- public class ThreadPoolConfig {
- @Bean(name = "taskExecutor")
- public Executor taskExecutor() {
- ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
- executor.setCorePoolSize(20); // 核心线程池大小
- executor.setMaxPoolSize(50); // 最大线程池大小
- executor.setQueueCapacity(150); // 队列容量
- executor.setThreadNamePrefix("Async-"); // 线程名称前缀
- executor.initialize();
- return executor;
- }
- }
|