From ecfd78ff93d3c41a7a4332b6716105da10348f55 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Sun, 25 Jan 2026 10:52:37 +0100 Subject: [PATCH] Polishing (aligned with main) --- .../springframework/core/task/AsyncTaskExecutor.java | 11 +++-------- .../core/task/SimpleAsyncTaskExecutor.java | 11 ++++++----- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/spring-core/src/main/java/org/springframework/core/task/AsyncTaskExecutor.java b/spring-core/src/main/java/org/springframework/core/task/AsyncTaskExecutor.java index ced54f6db17..3487dd31dcb 100644 --- a/spring-core/src/main/java/org/springframework/core/task/AsyncTaskExecutor.java +++ b/spring-core/src/main/java/org/springframework/core/task/AsyncTaskExecutor.java @@ -25,14 +25,10 @@ import org.springframework.util.concurrent.FutureUtils; /** * Extended interface for asynchronous {@link TaskExecutor} implementations, - * offering support for {@link java.util.concurrent.Callable}. - * - *

Note: The {@link java.util.concurrent.Executors} class includes a set of - * methods that can convert some other common closure-like objects, for example, - * {@link java.security.PrivilegedAction} to {@link Callable} before executing them. + * offering support for {@link Future}/{@link CompletableFuture} handles. * *

Implementing this interface also indicates that the {@link #execute(Runnable)} - * method will not execute its Runnable in the caller's thread but rather + * method will not execute the given Runnable in the caller's thread but rather * asynchronously in some other thread. * * @author Juergen Hoeller @@ -125,8 +121,7 @@ public interface AsyncTaskExecutor extends TaskExecutor { /** * Submit a {@code Callable} task for execution, receiving a {@code CompletableFuture} - * representing that task. The Future will return the Callable's result upon - * completion. + * representing that task. The Future will return the Callable's result upon completion. * @param task the {@code Callable} to execute (never {@code null}) * @return a {@code CompletableFuture} representing pending completion of the task * @throws TaskRejectedException if the given task was not accepted 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 16f339621df..54e47b8e7e7 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 @@ -32,13 +32,13 @@ import org.springframework.util.concurrent.ListenableFuture; import org.springframework.util.concurrent.ListenableFutureTask; /** - * {@link TaskExecutor} implementation that fires up a new Thread for each task, - * executing it asynchronously. Provides a virtual thread option on JDK 21. + * {@link TaskExecutor} implementation that fires up a new Thread for each task. + * Provides a {@link #setVirtualThreads virtual threads} option on JDK 21+. * *

Supports a graceful shutdown through {@link #setTaskTerminationTimeout}, * at the expense of task tracking overhead per execution thread at runtime. - * Supports limiting concurrent threads through {@link #setConcurrencyLimit}. - * By default, the number of concurrent task executions is unlimited. + * Supports limiting concurrent threads through {@link #setConcurrencyLimit}; + * by default, the number of concurrent task executions is unlimited. * *

NOTE: This implementation does not reuse threads! Consider a * thread-pooling TaskExecutor implementation instead, in particular for @@ -217,10 +217,11 @@ public class SimpleAsyncTaskExecutor extends CustomizableThreadCreator /** * Specify whether to reject tasks when the concurrency limit has been reached, - * throwing {@link TaskRejectedException} on any further submission attempts. + * throwing {@link TaskRejectedException} on any further execution attempts. *

The default is {@code false}, blocking the caller until the submission can * be accepted. Switch this to {@code true} for immediate rejection instead. * @since 6.2.6 + * @see #setConcurrencyLimit */ public void setRejectTasksWhenLimitReached(boolean rejectTasksWhenLimitReached) { this.rejectTasksWhenLimitReached = rejectTasksWhenLimitReached;