ScheduledConfig.java 1014 B

12345678910111213141516171819202122232425262728293031323334
  1. package com.sqx.scheduler.config;
  2. import org.springframework.context.annotation.Configuration;
  3. import org.springframework.scheduling.annotation.AsyncConfigurer;
  4. import org.springframework.scheduling.annotation.EnableAsync;
  5. import org.springframework.scheduling.annotation.EnableScheduling;
  6. import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
  7. import java.util.concurrent.Executor;
  8. /**
  9. * 调度配置
  10. *
  11. * @auther: codingliang
  12. * @date: 2023/5/19 23:15
  13. * @description: 调度配置
  14. */
  15. @EnableAsync
  16. @EnableScheduling
  17. @Configuration
  18. public class ScheduledConfig implements AsyncConfigurer {
  19. @Override
  20. public Executor getAsyncExecutor() {
  21. ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
  22. executor.setCorePoolSize(20);
  23. executor.setMaxPoolSize(40);
  24. executor.setQueueCapacity(200);
  25. executor.setKeepAliveSeconds(60);
  26. executor.setThreadNamePrefix("wm-task-");
  27. executor.initialize();
  28. return executor;
  29. }
  30. }