1234567891011121314151617181920212223242526272829 |
- package org.springblade.common.utils;
- import org.springframework.context.annotation.Bean;
- import org.springframework.context.annotation.Configuration;
- import java.util.concurrent.*;
- @Configuration
- public class AsyncConfig {
- /**
- * cpu 核心数量
- */
- public static final int cpuNum = 1 ;//Runtime.getRuntime().availableProcessors();
- /**
- * 线程池配置
- * @return
- */
- @Bean("taskExecutor1")
- public ThreadPoolExecutor getAsyncExecutor() {
- return new ThreadPoolMonitor(cpuNum
- , 15
- , 600
- , TimeUnit.SECONDS
- , new LinkedBlockingQueue<>(2000)
- , new ThreadPoolExecutor.DiscardOldestPolicy(), "manager-thread-pool");
- }
- }
|