Document limited concurrency with fixed-delay tasks on virtual threads

Closes gh-31900
This commit is contained in:
Juergen Hoeller 2023-12-26 10:59:13 +01:00
parent a428955438
commit 17d362fa85
2 changed files with 9 additions and 1 deletions

View File

@ -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 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 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 `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).

View File

@ -131,6 +131,9 @@ public @interface Scheduled {
* last invocation and the start of the next. * last invocation and the start of the next.
* <p>The time unit is milliseconds by default but can be overridden via * <p>The time unit is milliseconds by default but can be overridden via
* {@link #timeUnit}. * {@link #timeUnit}.
* <p><b>NOTE: With virtual threads, fixed rates and cron triggers are recommended
* over fixed delays.</b> Fixed-delay tasks operate on a single scheduler thread
* with {@link org.springframework.scheduling.concurrent.SimpleAsyncTaskScheduler}.
* @return the delay * @return the delay
*/ */
long fixedDelay() default -1; long fixedDelay() default -1;
@ -142,6 +145,9 @@ public @interface Scheduled {
* {@link #timeUnit}. * {@link #timeUnit}.
* <p>This attribute variant supports Spring-style "${...}" placeholders * <p>This attribute variant supports Spring-style "${...}" placeholders
* as well as SpEL expressions. * as well as SpEL expressions.
* <p><b>NOTE: With virtual threads, fixed rates and cron triggers are recommended
* over fixed delays.</b> Fixed-delay tasks operate on a single scheduler thread
* with {@link org.springframework.scheduling.concurrent.SimpleAsyncTaskScheduler}.
* @return the delay as a String value &mdash; for example, a placeholder * @return the delay as a String value &mdash; for example, a placeholder
* or a {@link java.time.Duration#parse java.time.Duration} compliant value * or a {@link java.time.Duration#parse java.time.Duration} compliant value
* @since 3.2.2 * @since 3.2.2