79591400

Date: 2025-04-24 20:23:32
Score: 2
Natty:
Report link

@Scheduled tasks are synchronous by default, new tasks won't be triggered unless the previous one gets completed.

@Scheduled(fixedRate = 2000)
public void synchronousTask(){
// new task will be trigged only if previous job gets completed.
}

If you want async task use @Async tag along with @Scheduled tag, also you need to configure the threed pool size

spring.task.scheduling.pool.size = 2 //configure the pool size based on your usecase
@Async
@Scheduled(fixedRate = 2000)
public void asyncTask(){
// this task wont wait for completion of previous task
}
Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • User mentioned (1): @Scheduled
  • User mentioned (0): @Async
  • User mentioned (0): @Scheduled
  • Looks like a comment (1):
  • Low reputation (1):
Posted by: nuclear_nadal