Application.java启动类中增加线程池初始化。
@Bean(name = "threadPool")
public static ExecutorService threadPool() {
int max = Runtime.getRuntime().availableProcessors() + 1;
return new ThreadPoolExecutor(max, max, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>());
}
使用方法
@Autowired
@Qualifier(value = "threadPool")
private ExecutorService threadPool;