I'm using spring-boot
and @Scheduled
annotation to execute some tasks.
How can I find out what the default pool size of scheduled tasks is by default in spring-boot?
Reason: the following class does not execute the jobs in parallel, but one after the other. Maybe only a single thread executor is configured by default?
@Service
public class ZipFileTesterAsync {
@Scheduled(fixedDelay = 60000, initialDelay = 500)
public void run() throws Exception {
System.out.println("import 1");
TimeUnit.MINUTES.sleep(1);
System.out.println("import 1 finished");
}
@Scheduled(fixedDelay = 60000, initialDelay = 1000)
public void run2() throws Exception {
System.out.println("import 2");
TimeUnit.MINUTES.sleep(1);
}
}
Result: the 2nd job is executed after the first finished.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…