import lombok.extern.slf4j.Slf4j;
import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.AsyncConfigurer;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import java.util.concurrent.Executor;
import java.util.concurrent.ThreadPoolExecutor;
/**
* @Description: 线程池配置
* ComponentScan填服务的路径
*/
@Configuration
@ComponentScan("xxx.xxx.xxx")
@EnableAsync
@Slf4j
public class ThreadPoolConfig implements AsyncConfigurer {
//参数初始化
private static final int CPU_COUNT = Runtime.getRuntime().availableProcessors();
//核心线程数量大小
private static final int corePoolSize = Math.max(2, Math.
JAVA-线程池配置
最新推荐文章于 2024-07-05 14:48:07 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)