回复:回复:Virtual thread hang and all threads stop running on JDK21

何品(虎鸣) hepin.p at alibaba-inc.com
Tue Jun 25 04:05:54 UTC 2024


The code below will dead lock
-Djdk.virtualThreadScheduler.parallelism=1
-Djdk.virtualThreadScheduler.maxPoolSize=1
-Djdk.virtualThreadScheduler.minRunnable=1
public class VTTest {
 static final CountDownLatch countDownLatch = new CountDownLatch(1);
 static final ExecutorService executor = Executors.newVirtualThreadPerTaskExecutor();
 public static void main(String[] args) throws IOException {
 executor.execute(() -> {
 try {
 Thread.sleep(1000);
 } catch (InterruptedException e) {
 throw new RuntimeException(e);
 }
 countDownLatch.countDown();
 });
 executor.execute(InnerSleepClass::hello);
 System.in.read();
 }
 private static class InnerSleepClass {
 static {
 try {
 countDownLatch.await();
 System.out.println("exit count down.");
 } catch (InterruptedException e) {
 throw new RuntimeException(e);
 }
 }
 static void hello() {
 System.out.println("hello");
 }
 }
}
------------------------------------------------------------------
发件人:何品(虎鸣) <hepin.p at alibaba-inc.com>
发送时间:2024年6月23日(星期日) 16:30
收件人:Alan Bateman<Alan.Bateman at oracle.com>; masoud parvari<masoud.parvari at gmail.com>; "何品(虎鸣)"<hepin.p at alibaba-inc.com>
抄 送:"loom-dev"<loom-dev at openjdk.org>
主 题:回复:回复:Virtual thread hang and all threads stop running on JDK21
Thanks for the clarification
------------------------------------------------------------------
发件人:Alan Bateman <Alan.Bateman at oracle.com>
发送时间:2024年6月22日(星期六) 17:22
收件人:masoud parvari<masoud.parvari at gmail.com>; "何品(虎鸣)"<hepin.p at alibaba-inc.com>
抄 送:"loom-dev"<loom-dev at openjdk.org>
主 题:Re: 回复:Virtual thread hang and all threads stop running on JDK21
 On 22/06/2024 09:54, masoud parvari wrote:
In class loading/initialization cases, the underlying issue is that pinning happens because there are native frames in the stack, so replacing the synchronized with a j.u.c lock will still lead to the same issue.
 That's right, and there are a couple of scenarios there, to be looked into after the object monitor issues are out of the way.
 -Alan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/loom-dev/attachments/20240625/554b9d5a/attachment.htm>


More information about the loom-dev mailing list