场景:
项目采用springboot搭建,想给方法添加@Scheduled注解,实现两个定时任务。但两个定时任务没有并发执行,而是执行完一个task才会执行另外一个。
package com.autohome.contentplatform.tasks;
import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
@Component
@Configurable
@EnableScheduling
public class task1 {
@Scheduled(cron = "0/5 * * * * ? ")
public void startSchedule() {
System.out.println("===========1=>");
try {
for(int i=1;i<=10;i++){
System.out.println("=1==>"+i);
Thread.sleep(1000);
}
} catch (InterruptedException e) {
e.printStackTrace();
}
}
@Scheduled(cron = "0/5 * * * * ? ")
public void sta