Browse Source

Polishing (aligned with main)

6.2.x
Juergen Hoeller 1 week ago
parent
commit
ecfd78ff93
  1. 11
      spring-core/src/main/java/org/springframework/core/task/AsyncTaskExecutor.java
  2. 11
      spring-core/src/main/java/org/springframework/core/task/SimpleAsyncTaskExecutor.java

11
spring-core/src/main/java/org/springframework/core/task/AsyncTaskExecutor.java

@ -25,14 +25,10 @@ import org.springframework.util.concurrent.FutureUtils; @@ -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}.
*
* <p>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.
*
* <p>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 { @@ -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

11
spring-core/src/main/java/org/springframework/core/task/SimpleAsyncTaskExecutor.java

@ -32,13 +32,13 @@ import org.springframework.util.concurrent.ListenableFuture; @@ -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+.
*
* <p>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.
*
* <p><b>NOTE: This implementation does not reuse threads!</b> Consider a
* thread-pooling TaskExecutor implementation instead, in particular for
@ -217,10 +217,11 @@ public class SimpleAsyncTaskExecutor extends CustomizableThreadCreator @@ -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.
* <p>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;

Loading…
Cancel
Save