Re: Tomcat 10 and virtual thread

Christopher Schultz <[email protected]>
Newsgroups gmane.comp.jakarta.tomcat.user
Message-ID <[email protected]>
Francois,

On 11/3/25 11:04 AM, COURTAULT Francois wrote:
> Looking at https://tomcat.apache.org/tomcat-10.1-doc/config/
> executor.html we can configure Tomcat 10.1.x to use virtual threads
> instead of platform threads. Do you confirm ?
Yes.

> The way to do it, as far as I understood, is to:
> 
>    *   first, declare an executor in server.xml like below
> <Executor name="virtualThread"
>                                        className="org.apache.catalina.core.StandardVirtualThreadExecutor" />
 > >    *   second, use a connector which will refer this above Executor 
thanks to its name attribute.
> The way I do it, is to update line 74, in server.xml, from <Connector port="8080" protocol="HTTP/1.1" to
>                                                                                                                           <Connector executor="virtualThread" port="8080" protocol="HTTP/1.1"

+1

> I started Tomcat and triggered a thread dump.
> I was not able to see any tomcat-virt string.
> Does it mean that the virtual thread usage is still disabled ?
> 
> What's wrong with my configuration ?

Do you have other <Connector>s configured? Are you sure Tomcat (a) was 
stopped before you started it and (b) started successfully when you 
started it? Is there anything in the logs?

Use of Virtual Threads requires that you are running a Java version that 
supports them. VT were added in Java 19 (as a preview), released as a 
standard feature in Java 21, and improved a few times thereafter.

I wouldn't use Virtual Threads before Java 24 because Java 24 removes 
the thread-pinning behavior of previous versions inside of synchronized 
blocks. Before Java 24, VT can't be considered a general-purpose feature 
IMHO.

-chris
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.