|
@@ -4,11 +4,8 @@ import com.ruoyi.common.utils.Threads;
|
|
|
import org.apache.commons.lang3.concurrent.BasicThreadFactory;
|
|
|
import org.springframework.context.annotation.Bean;
|
|
|
import org.springframework.context.annotation.Configuration;
|
|
|
-import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
|
|
|
|
|
-import java.util.concurrent.ScheduledExecutorService;
|
|
|
-import java.util.concurrent.ScheduledThreadPoolExecutor;
|
|
|
-import java.util.concurrent.ThreadPoolExecutor;
|
|
|
+import java.util.concurrent.*;
|
|
|
|
|
|
/**
|
|
|
* 线程池配置
|
|
@@ -32,15 +29,15 @@ public class ThreadPoolConfig {
|
|
|
public static final String threadPoolTaskExecutor = "threadPoolTaskExecutor";
|
|
|
|
|
|
@Bean(name = threadPoolTaskExecutor)
|
|
|
- public ThreadPoolTaskExecutor threadPoolTaskExecutor() {
|
|
|
- ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
|
|
|
- executor.setMaxPoolSize(maxPoolSize);
|
|
|
- executor.setCorePoolSize(corePoolSize);
|
|
|
- executor.setQueueCapacity(queueCapacity);
|
|
|
- executor.setKeepAliveSeconds(keepAliveSeconds);
|
|
|
- // 线程池对拒绝任务(无线程可用)的处理策略
|
|
|
- executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
|
|
|
- return executor;
|
|
|
+ public ThreadPoolExecutor threadPoolTaskExecutor() {
|
|
|
+ return new ThreadPoolExecutor(
|
|
|
+ 10,
|
|
|
+ 20,
|
|
|
+ 60,
|
|
|
+ TimeUnit.SECONDS,
|
|
|
+ new ArrayBlockingQueue<>(30),
|
|
|
+ new ThreadPoolExecutor.CallerRunsPolicy()
|
|
|
+ );
|
|
|
}
|
|
|
|
|
|
/**
|