<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-webflux</artifactId> </dependency>

I am using the above dependency to build my application, and I am also using JDK 21. I want to leverage the new feature of JDK 21 - virtual threads. I have set spring.threads.virtual.enabled=true to enable virtual threads. I created an endpoint to test whether virtual threads are running:

@PostMapping("/test") public Mono<Void> test() { System.out.println("----->>>>>>>> " + Thread.currentThread()); return Mono.empty(); }

However, the output of System.out shows: ----->>>>>>>>Thread[#75,reactor-http-nio-2,5,main] This clearly indicates a traditional thread name. I am unsure why virtual threads are not taking effect.

Comment From: MrWangGang

I have found the reason. Webflux uses Netty by default for startup, while spring.threads.virtual.enabled=true is specific to the Tomcat container. Therefore, I can simply switch from Netty to Tomcat to use virtual threads. However, I still hope that the official team can provide a solution for Netty to use virtual threads as well.

Comment From: bclozel

As far as I know we would need Netty to support Virtual Threads in the first place. Closing in favor of https://github.com/netty/netty/issues/12848