Is there a Spring Boot configuration parameter to switch between virtual threads and platform threads?
Asked Answered
B

1

5

Is there a standard built-in Spring Boot configuration parameter to tell whether to use virtual threads or platform threads for rest controller?

Or is the only way to create configuration beans, like described e.g. here https://www.baeldung.com/spring-6-virtual-threads?

Benbena answered 24/10, 2023 at 15:39 Comment(2)
At the moment there isn't. With Spring BOot 3.2 there is spring.threads.virtual.enabled=true.Nickel
A more detailed document about trying things around with spring boot and JDK-21 can be found here.Interpretive
N
6

For the current supported Spring Boot versions (at the moment that is up to Spring Boot 3.1) doing manual configuration is the only way.

As of Spring Boot 3.2 it is a matter of enabling it in your configuration by setting spring.threads.virtual.enabled to true in your application.properties.

Spring Boot will then automatically switch to virtual threads.

Nickel answered 24/10, 2023 at 18:2 Comment(2)
That's promising :) What is the default setting in Spring Boot 3.1, if I do not provide an explicit configuration?Benbena
What default setting? No virtual threads as there is no Java21 support out-of-the-box (like with Spring 6.1 and Spring Boot 3.2).Nickel

© 2022 - 2025 — McMap. All rights reserved.