Spring: @Scheduled runs on a single thread by default

One slow job delays every other scheduled job unless you give the scheduler a pool.

Code
@EnableScheduling
@Configuration
class SchedulingConfig {
    @Bean
    TaskScheduler taskScheduler() {
        var s = new ThreadPoolTaskScheduler();
        s.setPoolSize(5);            // without this: 1
        return s;
    }
}

@Scheduled(fixedDelay = 60_000)
void reap() { ... }

@Scheduled(cron = "0 0 3 * * *", zone = "Asia/Kolkata")
void nightly() { ... }
Output
Default pool size is 1: a 10-minute job blocks the reaper for 10 minutes.
fixedDelay waits AFTER completion; fixedRate waits from the start.
Advertisement

Run this yourself in the Online Java Compiler, spin up a live REST API in the API Sandbox, or practise with Java interview questions.

Published 2026-08-11