|
|
|
@ -32,13 +32,13 @@ import org.springframework.util.concurrent.ListenableFuture; |
|
|
|
import org.springframework.util.concurrent.ListenableFutureTask; |
|
|
|
import org.springframework.util.concurrent.ListenableFutureTask; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* {@link TaskExecutor} implementation that fires up a new Thread for each task, |
|
|
|
* {@link TaskExecutor} implementation that fires up a new Thread for each task. |
|
|
|
* executing it asynchronously. Provides a virtual thread option on JDK 21. |
|
|
|
* Provides a {@link #setVirtualThreads virtual threads} option on JDK 21+. |
|
|
|
* |
|
|
|
* |
|
|
|
* <p>Supports a graceful shutdown through {@link #setTaskTerminationTimeout}, |
|
|
|
* <p>Supports a graceful shutdown through {@link #setTaskTerminationTimeout}, |
|
|
|
* at the expense of task tracking overhead per execution thread at runtime. |
|
|
|
* at the expense of task tracking overhead per execution thread at runtime. |
|
|
|
* Supports limiting concurrent threads through {@link #setConcurrencyLimit}. |
|
|
|
* Supports limiting concurrent threads through {@link #setConcurrencyLimit}; |
|
|
|
* By default, the number of concurrent task executions is unlimited. |
|
|
|
* by default, the number of concurrent task executions is unlimited. |
|
|
|
* |
|
|
|
* |
|
|
|
* <p><b>NOTE: This implementation does not reuse threads!</b> Consider a |
|
|
|
* <p><b>NOTE: This implementation does not reuse threads!</b> Consider a |
|
|
|
* thread-pooling TaskExecutor implementation instead, in particular for |
|
|
|
* 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, |
|
|
|
* 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 |
|
|
|
* <p>The default is {@code false}, blocking the caller until the submission can |
|
|
|
* be accepted. Switch this to {@code true} for immediate rejection instead. |
|
|
|
* be accepted. Switch this to {@code true} for immediate rejection instead. |
|
|
|
* @since 6.2.6 |
|
|
|
* @since 6.2.6 |
|
|
|
|
|
|
|
* @see #setConcurrencyLimit |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void setRejectTasksWhenLimitReached(boolean rejectTasksWhenLimitReached) { |
|
|
|
public void setRejectTasksWhenLimitReached(boolean rejectTasksWhenLimitReached) { |
|
|
|
this.rejectTasksWhenLimitReached = rejectTasksWhenLimitReached; |
|
|
|
this.rejectTasksWhenLimitReached = rejectTasksWhenLimitReached; |
|
|
|
|