<div dir="ltr">Hi.<div><br></div><div>As often mentioned in this mailing-list a feedback about preview/incubator features is appreciated, so here's one: </div><div><br></div><div>I was experimenting with a caching system utilising ConcurrentHashMap as cache store and Structured Concurrency API for refreshing the entries from multiple sources ( StructuredTaskScope.ShutdownOnSuccess ). The idea was to make http-requests for getting the fresh values but the first implementation simply uses UUID::randomUUID for simulating that.</div><div> </div><div>I noticed that the programs halts In a test case where "N" concurrent calls (where "N" >= number of cpu cores) running on virtual threads end-up calling the ConcurrentHashMap::computeIfAbsent for the same (non-existing) key.<br></div><div><br></div><div>"-Djdk.tracePinnedThreads=full" reveals that there is a pinned carrier thread:</div><div><div>  java.base/java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1708) <== monitors:1<br></div><div><br></div></div><div>The documentation ( <a href="https://docs.oracle.com/en/java/javase/19/docs/api/java.base/java/util/concurrent/ConcurrentHashMap.html#computeIfAbsent(K,java.util.function.Function)">https://docs.oracle.com/en/java/javase/19/docs/api/java.base/java/util/concurrent/ConcurrentHashMap.html#computeIfAbsent(K,java.util.function.Function)</a> ) says:</div><div><div><br></div></div><div>  "Some attempted update operations on this map by other threads may be blocked while computation is in progress, so the computation should be short and simple."</div><div><br></div><div>This is clear but I still found it as a surprise that it uses synchronized instead of "virtual-thread friendly" constructs.</div><div><br></div><div>If needed I can post a small demo program.</div><div><br></div><div>JDK used is latest OpenJDK-19 GA, OS is Windows:</div><div>  openjdk version "19.0.2" 2023-01-17<br>  OpenJDK Runtime Environment (build 19.0.2+7-44)<br>  OpenJDK 64-Bit Server VM (build 19.0.2+7-44, mixed mode, sharing)<br></div><div><br></div><div>Best Regards,</div><div>  Mika</div></div>