diff --git a/framework-docs/modules/ROOT/pages/integration/scheduling.adoc b/framework-docs/modules/ROOT/pages/integration/scheduling.adoc index cc8e0e2cd5..8c4358b41c 100644 --- a/framework-docs/modules/ROOT/pages/integration/scheduling.adoc +++ b/framework-docs/modules/ROOT/pages/integration/scheduling.adoc @@ -252,7 +252,9 @@ application server environments, as well -- in particular on Tomcat and Jetty. As of 6.1, `ThreadPoolTaskScheduler` provides a pause/resume capability and graceful shutdown through Spring's lifecycle management. There is also a new option called `SimpleAsyncTaskScheduler` which is aligned with JDK 21's Virtual Threads, using a -single scheduler thread but firing up a new thread for every scheduled task execution. +single scheduler thread but firing up a new thread for every scheduled task execution +(except for fixed-delay tasks which all operate on a single scheduler thread, so for +this virtual-thread-aligned option, fixed rates and cron triggers are recommended). diff --git a/spring-context/src/main/java/org/springframework/scheduling/annotation/Scheduled.java b/spring-context/src/main/java/org/springframework/scheduling/annotation/Scheduled.java index 43436644ca..4ee75d0cd9 100644 --- a/spring-context/src/main/java/org/springframework/scheduling/annotation/Scheduled.java +++ b/spring-context/src/main/java/org/springframework/scheduling/annotation/Scheduled.java @@ -131,6 +131,9 @@ public @interface Scheduled { * last invocation and the start of the next. *

The time unit is milliseconds by default but can be overridden via * {@link #timeUnit}. + *

NOTE: With virtual threads, fixed rates and cron triggers are recommended + * over fixed delays. Fixed-delay tasks operate on a single scheduler thread + * with {@link org.springframework.scheduling.concurrent.SimpleAsyncTaskScheduler}. * @return the delay */ long fixedDelay() default -1; @@ -142,6 +145,9 @@ public @interface Scheduled { * {@link #timeUnit}. *

This attribute variant supports Spring-style "${...}" placeholders * as well as SpEL expressions. + *

NOTE: With virtual threads, fixed rates and cron triggers are recommended + * over fixed delays. Fixed-delay tasks operate on a single scheduler thread + * with {@link org.springframework.scheduling.concurrent.SimpleAsyncTaskScheduler}. * @return the delay as a String value — for example, a placeholder * or a {@link java.time.Duration#parse java.time.Duration} compliant value * @since 3.2.2