场景
SpringBoot中定时任务与异步定时任务的实现:
SpringBoot中定时任务与异步定时任务的实现_霸道流氓气质的博客-CSDN博客
使用SpringBoot原生方式实现定时任务,已经开启多线程支持,以上是方式之一。
除此之外还可通过如下方式。
为什么Spring Boot 定时任务是单线程的?
查看注解@EnableScheduling源码可知
protected void scheduleTasks() {
if (this.taskScheduler == null) {
this.localExecutor = Executors.newSingleThreadScheduledExecutor();
this.taskScheduler = new ConcurrentTaskScheduler(this.localExecutor);