Re: Tomcat 10 and virtual thread
William Crowell <[email protected]>
| Newsgroups | gmane.comp.jakarta.tomcat.user |
|---|---|
| Message-ID | <PH8PR20MB5193CFE7414DEF947AD26A98B4C7A@PH8PR20MB5193.namprd20.prod.outlook.com> |
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.