How to wait until the scheduled task completes execution

108 views Asked by At

How to wait until the scheduled task completes execution, before starting the next iteration. The following options all fail to work

@Scheduled(cron = "*/30 * * * * *")
@Scheduled(fixedDelay = 30000, initialDelay = 1000)
@Scheduled(fixedRate = 30000, initialDelay = 1000)

I have a thread pool of 100 for running long running tasks within a single iteration

@Configuration
public class SchedulerConfiguration implements SchedulingConfigurer {

    @Bean
    public Executor taskExecutor() {
        return Executors.newScheduledThreadPool(100);
    }   

    @Override
    public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
        taskRegistrar.setScheduler(taskExecutor());
    }   

}

Refer https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/scheduling/annotation/Scheduled.html

0

There are 0 answers