Virtual threads created more platform threads
Alan Bateman
alan.bateman at oracle.com
Thu Jul 3 06:50:53 UTC 2025
On 03/07/2025 02:14, Jianbin Chen wrote:
> Sorry to bother you all again. When using virtual threads on JDK 21,
> I've always been concerned about potential pinning situations, so
> during testing in our offline environment, we always add the
> -Djdk.tracePinnedThreads=full parameter. However, we have never seen
> any pinned-related information output. Yesterday I conducted a test
> and found that when using synchronized + object.wait(), even though
> the maximum number of platform threads used by virtual threads has
> already reached the limit, it still cannot output pinned-related logs.
> But if I switch to synchronized + Thread.sleep(), it can output the
> logs. I'm providing my example and JVM parameters below, hoping
> someone can help explain this issue. Thank you very much.
That rudimentary tracing/debug option printed a stack trace when a
virtual thread parked inside a synchronized method. It didn't help with
Object.wait or other cases.
Once you get to JDK 24+ you can drop -Djdk.tracePinnedThreads=full as
this system property has no effect. The changes to object monitors in
JDK 24, and the improvements to JFR events for pinning in the same
release, means the tracing option isn't needed.
-Alan
More information about the loom-dev
mailing list