From 323de1208acf00ebd3bb022055a381907f3c2de4 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Mon, 28 Oct 2024 22:08:41 +0100 Subject: [PATCH] Document limited support for lifecycle management Closes gh-33780 --- .../scheduling/concurrent/SimpleAsyncTaskScheduler.java | 4 +++- .../springframework/core/task/SimpleAsyncTaskExecutor.java | 5 +++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/spring-context/src/main/java/org/springframework/scheduling/concurrent/SimpleAsyncTaskScheduler.java b/spring-context/src/main/java/org/springframework/scheduling/concurrent/SimpleAsyncTaskScheduler.java index 027d1f6f4f47..d585470e4cf8 100644 --- a/spring-context/src/main/java/org/springframework/scheduling/concurrent/SimpleAsyncTaskScheduler.java +++ b/spring-context/src/main/java/org/springframework/scheduling/concurrent/SimpleAsyncTaskScheduler.java @@ -78,7 +78,9 @@ * but rather just the hand-off to an execution thread. As a consequence, * a {@link ScheduledFuture} handle (e.g. from {@link #schedule(Runnable, Instant)}) * represents that hand-off rather than the actual completion of the provided task - * (or series of repeated tasks). + * (or series of repeated tasks). Also, this scheduler participates in lifecycle + * management to a limited degree only, stopping trigger firing and fixed-delay + * task execution but not stopping the execution of handed-off tasks. * *

As an alternative to the built-in thread-per-task capability, this scheduler * can also be configured with a separate target executor for scheduled task diff --git a/spring-core/src/main/java/org/springframework/core/task/SimpleAsyncTaskExecutor.java b/spring-core/src/main/java/org/springframework/core/task/SimpleAsyncTaskExecutor.java index 4206695f0b42..8412e6c4aff9 100644 --- a/spring-core/src/main/java/org/springframework/core/task/SimpleAsyncTaskExecutor.java +++ b/spring-core/src/main/java/org/springframework/core/task/SimpleAsyncTaskExecutor.java @@ -46,6 +46,11 @@ * executing a large number of short-lived tasks. Alternatively, on JDK 21, * consider setting {@link #setVirtualThreads} to {@code true}. * + *

NOTE: This executor does not participate in context-level lifecycle + * management. Tasks on handed-off execution threads cannot be centrally + * stopped and restarted; if such tight lifecycle management is necessary, + * consider a common {@code ThreadPoolTaskExecutor} setup instead. + * * @author Juergen Hoeller * @since 2.0 * @see #setVirtualThreads