<div dir="auto">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.<div dir="auto"><br></div><div dir="auto">JVM parameters: -Djdk.tracePinnedThreads=full -Djava.util.concurrent.ForkJoinPool.common.parallelism=2 -Djdk.virtualThreadScheduler.parallelism=2 -Djava.util.concurrent.ForkJoinPool.common.maximumSpares=2 -Djdk.virtualThreadScheduler.maxPoolSize=2</div><div dir="auto"><br></div><div dir="auto">```</div><div dir="auto">public static void main(String[] args) throws InterruptedException {</div><div dir="auto"> Executor executor = ThreadPoolFactory.newVirtualThreadPerTaskExecutor();</div><div dir="auto"> List<String> list = new ArrayList<>();</div><div dir="auto"> for (int i = 0; i < 20; i++) {</div><div dir="auto"> list.add(String.valueOf(i));</div><div dir="auto"> }</div><div dir="auto"> for (int i = 0; i < list.size(); i++) {</div><div dir="auto"> String value = list.get(i);</div><div dir="auto"> executor.execute(() -> {</div><div dir="auto"> synchronized (value) {</div><div dir="auto"> try {</div><div dir="auto"> value.wait();</div><div dir="auto"> } catch (InterruptedException e) {</div><div dir="auto"> throw new RuntimeException(e);</div><div dir="auto"> }</div><div dir="auto"> }</div><div dir="auto"> });</div><div dir="auto"> }</div><div dir="auto"> Thread.sleep(120000);</div><div dir="auto">}</div><div dir="auto">```<br><br><div data-smartmail="gmail_signature" dir="auto">Best Regards.<br>Jianbin Chen, github-id: funky-eyes </div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Alan Bateman <<a href="mailto:alan.bateman@oracle.com">alan.bateman@oracle.com</a>> 于 2025年7月2日周三 17:19写道:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
<br>
On 02/07/2025 09:27, Andrew Haley wrote:<br>
> On 02/07/2025 05:15, Peter Eastham wrote:<br>
>> As Java 21 is still the current LTS, it isn't completely unreasonable to<br>
>> forward concerns to the mailing list.<br>
><br>
> Sure, we'e happy to talk about it, but as far as this group is <br>
> concerned the issue has been resolved.<br>
<br>
Right, and as a reminder: the changes were to the lightweight locking <br>
mode only (not legacy) and that mode only became the default in JDK 22. <br>
There is also a prerequisite spec change to JVMTI GetObjectMonitorUsage <br>
that happened in JDK 23. It also seems pointless given that JDK 24 is <br>
already released and JDK 25 is very close.<br>
<br>
-Alan<br>
</blockquote></div>