1234567891011121314151617181920212223242526272829 |
- package com.ruoyi.sim.config;
- import org.springframework.context.annotation.Bean;
- import org.springframework.context.annotation.Configuration;
- import org.springframework.scheduling.annotation.EnableAsync;
- import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
- import java.util.concurrent.ThreadPoolExecutor;
- /**
- * 非核心业务的线程池。
- */
- @Configuration
- @EnableAsync
- public class AsyncLogThreadPoolConfig {
- @Bean(name = "tp-log")
- public ThreadPoolTaskExecutor executor() {
- ThreadPoolTaskExecutor e = new ThreadPoolTaskExecutor();
- e.setCorePoolSize(10);
- e.setMaxPoolSize(100);
- e.setQueueCapacity(50);
- e.setKeepAliveSeconds(200);
- e.setThreadNamePrefix("tp-log-");
- e.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
- e.initialize();
- return e;
- }
- }
|