|
@@ -0,0 +1,38 @@
|
|
|
+package com.jianxun.gaudi.qs.scheduler;
|
|
|
+
|
|
|
+import org.springframework.context.annotation.Bean;
|
|
|
+import org.springframework.context.annotation.Configuration;
|
|
|
+import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
|
|
+
|
|
|
+import java.util.concurrent.Executor;
|
|
|
+import java.util.concurrent.ThreadPoolExecutor;
|
|
|
+
|
|
|
+
|
|
|
+ * @author xc
|
|
|
+ * @description
|
|
|
+ * @date 2022/7/6 18:26
|
|
|
+ */
|
|
|
+@Configuration
|
|
|
+public class SchedulerConfig {
|
|
|
+
|
|
|
+ @Bean("myAsync")
|
|
|
+ public Executor myAsync() {
|
|
|
+ ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
|
|
|
+
|
|
|
+ executor.setMaxPoolSize(20);
|
|
|
+
|
|
|
+ executor.setCorePoolSize(20);
|
|
|
+
|
|
|
+ executor.setQueueCapacity(100);
|
|
|
+
|
|
|
+ executor.setThreadNamePrefix("New-Thread-");
|
|
|
+
|
|
|
+ executor.setKeepAliveSeconds(60);
|
|
|
+
|
|
|
+ executor.setRejectedExecutionHandler(new ThreadPoolExecutor.AbortPolicy() {
|
|
|
+ });
|
|
|
+
|
|
|
+ executor.initialize();
|
|
|
+ return executor;
|
|
|
+ }
|
|
|
+}
|