Allow auto-configured applicationTaskExecutor to use virtual threads
With this commit, when virtual threads are enabled, the auto-configured applicationTaskExecutor changes from a ThreadPoolTaskExecutor to a SimpleAsyncTaskExecutor with virtual threads enabled. As before, any TaskDecorator bean is applied to the auto-configured executor and the spring.task.execution.thread-name-prefix property is applied. Other spring.task.execution.* properties are ignored as they are specific to a pool-based executor. Closes gh-35710
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
[[features.task-execution-and-scheduling]]
|
||||
== Task Execution and Scheduling
|
||||
In the absence of an `Executor` bean in the context, Spring Boot auto-configures a `ThreadPoolTaskExecutor` with sensible defaults that can be automatically associated to asynchronous task execution (`@EnableAsync`) and Spring MVC asynchronous request processing.
|
||||
In the absence of an `Executor` bean in the context, Spring Boot auto-configures an `AsyncTaskExecutor`.
|
||||
When virtual threads are enabled (using Java 21+ and configprop:spring.threads.virtual.enabled[] set to `true`) this will be a `SimpleAsyncTaskExecutor` that uses virtual threads.
|
||||
Otherwise, it will be a `ThreadPoolTaskExecutor` with sensible defaults.
|
||||
In either case, the auto-configured executor will be automatically used for asynchronous task execution (`@EnableAsync`) and Spring MVC asynchronous request processing.
|
||||
|
||||
[TIP]
|
||||
====
|
||||
@@ -10,7 +13,7 @@ Depending on your target arrangement, you could change your `Executor` into a `T
|
||||
The auto-configured `TaskExecutorBuilder` allows you to easily create instances that reproduce what the auto-configuration does by default.
|
||||
====
|
||||
|
||||
The thread pool uses 8 core threads that can grow and shrink according to the load.
|
||||
When a `ThreadPoolTaskExecutor` is auto-configured, the thread pool uses 8 core threads that can grow and shrink according to the load.
|
||||
Those default settings can be fine-tuned using the `spring.task.execution` namespace, as shown in the following example:
|
||||
|
||||
[source,yaml,indent=0,subs="verbatim",configprops,configblocks]
|
||||
|
||||
Reference in New Issue
Block a user