You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
Closesgh-35710
Copy file name to clipboardExpand all lines: spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/task/TaskExecutionAutoConfiguration.java
Copy file name to clipboardExpand all lines: spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/task/TaskExecutionAutoConfigurationTests.java
Copy file name to clipboardExpand all lines: spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/task-execution-and-scheduling.adoc
+5-2
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,9 @@
1
1
[[features.task-execution-and-scheduling]]
2
2
== Task Execution and Scheduling
3
-
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.
3
+
In the absence of an `Executor` bean in the context, Spring Boot auto-configures an `AsyncTaskExecutor`.
4
+
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.
5
+
Otherwise, it will be a `ThreadPoolTaskExecutor` with sensible defaults.
6
+
In either case, the auto-configured executor will be automatically used for asynchronous task execution (`@EnableAsync`) and Spring MVC asynchronous request processing.
4
7
5
8
[TIP]
6
9
====
@@ -10,7 +13,7 @@ Depending on your target arrangement, you could change your `Executor` into a `T
10
13
The auto-configured `TaskExecutorBuilder` allows you to easily create instances that reproduce what the auto-configuration does by default.
11
14
====
12
15
13
-
The thread pool uses 8 core threads that can grow and shrink according to the load.
16
+
When a `ThreadPoolTaskExecutor` is auto-configured, the thread pool uses 8 core threads that can grow and shrink according to the load.
14
17
Those default settings can be fine-tuned using the `spring.task.execution` namespace, as shown in the following example:
0 commit comments