zhou zhou
69 分钟以前 213917033bac65c5f0f48509ee9a8bde5cf6d54c
rsf-server/src/main/java/com/vincent/rsf/server/common/config/SchedulerConfig.java
@@ -2,13 +2,18 @@
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
import java.util.concurrent.Executor;
/**
 * Created by vincent on 11/12/2024
 */
@Configuration
@EnableAsync
@EnableScheduling
public class SchedulerConfig {
@@ -20,4 +25,18 @@
        return scheduler;
    }
    @Bean(name = "taskExecutor")
    public Executor taskExecutor() {
        ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
        executor.setCorePoolSize(8);
        executor.setMaxPoolSize(16);
        executor.setQueueCapacity(200);
        executor.setThreadNamePrefix("async-task-");
        executor.setWaitForTasksToCompleteOnShutdown(true);
        executor.setAwaitTerminationSeconds(30);
        executor.initialize();
        return executor;
    }
}