THALES GROUP LIMITED DISTRIBUTION to email recipients

Hello William,

Thanks for your feedback.

I am confused because the way (see underneath) I configured initially seems OK: 
it triggers the virtual thread usage. Indeed I am able to see 
ForkJoinPool-1-worker-1  😊 in the thread dump I triggered
   *   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"

If now I look at https://tomcat.apache.org/tomcat-10.1-doc/config/http.html
The useVirtualThreads attribute is listed under the Standard Implementation 
section which talks about standard HTTP connectors (NIO and NIO2).
So we should only use for protocol attribute one of the following 
Http11NioProtocol and Http11Nio2Protocol protocols.

In your configuration, you don't use one of these above protocols.

Why having several ways to enable virtual threads usage ?

So, what is the recommended configuration, for using virtual thread, to use ?
   - Define a new Executor with StandardVirtualThreadExecutor  as a className 
attribute
     Define a connector on HTTP protocol with an executor attribute set to the 
name of the new Executor
   - Or
        <Connector port="8080" 
protocol="org.apache.coyote.http11.Http11NioProtocol" or 
"org.apache.coyote.http11.Http11Nio2Protocol"
               connectionTimeout="20000"
               redirectPort="8443"
               maxParameterCount="1000"
               useVirtualThreads="true">
        </Connector>

BTW for HTTP1.0/1.1 traffic with no TLS what Connector should we use ?
     -   <Connector port="8080" protocol="HTTP/1.1"
    - or <Connector port="8080" protocol=" 
org.apache.coyote.http11.Http11NioProtocol"
    - or <Connector port="8080" protocol=" 
org.apache.coyote.http11.Http11Nio2Protocol"
?

Best Regards.

-----Original Message-----
From: William Crowell <[email protected]>
Sent: lundi 3 novembre 2025 17:15
To: Tomcat Users List <[email protected]>
Subject: Re: Tomcat 10 and virtual thread

Hi,

I have never tried doing it through the executor like that.  How I enable 
virtual threads in server.xml is like this:

 <Connector port="8080" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443"
               maxParameterCount="1000"
               useVirtualThreads="true" />

You should be using at least JDK21 for that to work.  When you do a thread dump 
you will see virtual threads in the dump.

Extra info FYI: Running with JVM argument -Djdk.tracePinnedThreads=full prints 
a complete stack trace when a thread blocks while pinned, with the native 
frames and frames holding monitors highlighted. Running with 
-Djdk.tracePinnedThreads=short limits the output to just the problematic frames:

Thread[#41,ForkJoinPool-1-worker-4,5,CarrierThreads]
    com.mysql.cj.jdbc.ConnectionImpl.isValid(ConnectionImpl.java:2516) <== 
monitors:1 Thread[#39,ForkJoinPool-1-worker-2,5,CarrierThreads]
    com.mysql.cj.jdbc.ConnectionImpl.isValid(ConnectionImpl.java:2516) <== 
monitors:1 Thread[#41,ForkJoinPool-1-worker-4,5,CarrierThreads]
    com.mysql.cj.jdbc.ConnectionImpl.setAutoCommit(ConnectionImpl.java:2005) 
<== monitors:1 Thread[#43,ForkJoinPool-1-worker-5,5,CarrierThreads]
    
com.mysql.cj.jdbc.ClientPreparedStatement.executeInternal(ClientPreparedStatement.java:893)
 <== monitors:1
    
com.mysql.cj.jdbc.ClientPreparedStatement.executeUpdateInternal(ClientPreparedStatement.java:1061)
 <== monitors:1
    
com.mysql.cj.jdbc.ClientPreparedStatement.executeUpdateInternal(ClientPreparedStatement.java:1009)
 <== monitors:1 Thread[#43,ForkJoinPool-1-worker-5,5,CarrierThreads]
    com.mysql.cj.jdbc.ConnectionImpl.commit(ConnectionImpl.java:791) <== 
monitors:1 Thread[#43,ForkJoinPool-1-worker-5,5,CarrierThreads]
    com.mysql.cj.jdbc.ConnectionImpl.setAutoCommit(ConnectionImpl.java:2005) 
<== monitors:1

Regards,

William Crowell

From: COURTAULT Francois <[email protected]>
Date: Monday, November 3, 2025 at 11:05 AM
To: [email protected] <[email protected]>
Subject: Tomcat 10 and virtual thread

[You don't often get email from [email protected]. 
Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]

THALES GROUP LIMITED DISTRIBUTION to email recipients

Hello everyone,

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 ?

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"

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 ?

Best Regards.






CAUTION: This email originated from outside of the organization. Do not click 
on links or open attachments unless you recognize the sender and know the 
content is safe.


This e-mail may contain information that is privileged or confidential. If you 
are not the intended recipient, please delete the e-mail and any attachments 
and notify us immediately.


Reply via email to