<div class="__aliyun_email_body_block"><div  style="clear:both;"><span  style="font-family:Tahoma,Arial,STHeiti,SimSun;">The code below will dead lock</span></div><div  style="clear:both;"><span  style="font-family:Tahoma,Arial,STHeiti,SimSun;"><br ></span></div><div  style="clear:both;"><span  style="font-family:Tahoma,Arial,STHeiti,SimSun;"><br ></span></div><div  style="clear:both;"><span  style="font-family:Tahoma,Arial,STHeiti,SimSun;"><span >-Djdk.virtualThreadScheduler.parallelism=1</span></span><div  style="clear:both;">-Djdk.virtualThreadScheduler.maxPoolSize=1</div><div ><span >-Djdk.virtualThreadScheduler.minRunnable=1</span></div><span  style="font-family:Tahoma,Arial,STHeiti,SimSun;"><br ></span></div><div  style="clear:both;"><span  style="font-family:Tahoma,Arial,STHeiti,SimSun;"><br ></span></div><div  style="clear:both;"><span  style="font-family:Tahoma,Arial,STHeiti,SimSun;"><br ></span></div><div  style="clear:both;"><span  style="font-family:Tahoma,Arial,STHeiti,SimSun;"><br ></span></div><div  style="clear:both;"><span  style="font-family:Tahoma,Arial,STHeiti,SimSun;"><span >public class VTTest {</span></span><div  style="clear:both;">    static final CountDownLatch countDownLatch = new CountDownLatch(1);</div><div  style="clear:both;">    static final ExecutorService executor = Executors.newVirtualThreadPerTaskExecutor();</div><div  style="clear:both;">    public static void main(String[] args) throws IOException {</div><div  style="clear:both;">        executor.execute(() -> {</div><div  style="clear:both;">            try {</div><div  style="clear:both;">                Thread.sleep(1000);</div><div  style="clear:both;">            } catch (InterruptedException e) {</div><div  style="clear:both;">                throw new RuntimeException(e);</div><div  style="clear:both;">            }</div><div  style="clear:both;">            countDownLatch.countDown();</div><div  style="clear:both;">        });</div><div  style="clear:both;">        executor.execute(InnerSleepClass::hello);</div><div  style="clear:both;">        System.in.read();</div><div  style="clear:both;">    }</div><div  style="clear:both;">    private static class InnerSleepClass {</div><div  style="clear:both;">        static {</div><div  style="clear:both;">            try {</div><div  style="clear:both;">                countDownLatch.await();</div><div  style="clear:both;">                System.out.println("exit count down.");</div><div  style="clear:both;">            } catch (InterruptedException e) {</div><div  style="clear:both;">                throw new RuntimeException(e);</div><div  style="clear:both;">            }</div><div  style="clear:both;">        }</div><div  style="clear:both;">        static void hello() {</div><div  style="clear:both;">            System.out.println("hello");</div><div  style="clear:both;">        }</div><div  style="clear:both;">    }</div><div ><span >}</span></div><span  style="font-family:Tahoma,Arial,STHeiti,SimSun;"><br ></span></div><blockquote  style="margin-right:.0px;margin-top:.0px;margin-bottom:.0px;font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14.0px;color:#000000;"><div  style="clear:both;">------------------------------------------------------------------</div><div  style="clear:both;">发件人:何品(虎鸣) <hepin.p@alibaba-inc.com></div><div  style="clear:both;">发送时间:2024年6月23日(星期日) 16:30</div><div  style="clear:both;">收件人:Alan Bateman<Alan.Bateman@oracle.com>; masoud parvari<masoud.parvari@gmail.com>; "何品(虎鸣)"<hepin.p@alibaba-inc.com></div><div  style="clear:both;">抄 送:"loom-dev"<loom-dev@openjdk.org></div><div  style="clear:both;">主 题:回复:回复:Virtual thread hang and all threads stop running on JDK21</div><div  style="clear:both;"><br ></div><div  style="clear:both;"><span  style="font-family:Tahoma,Arial,STHeiti,SimSun;">Thanks for the <span >clarification</span></span></div><div  style="clear:both;"><span  style="font-family:Tahoma,Arial,STHeiti,SimSun;"><br ></span></div><div  style="clear:both;"><span  style="font-family:Tahoma,Arial,STHeiti,SimSun;"><br ></span></div><div  style="clear:both;"><span  style="font-family:Tahoma,Arial,STHeiti,SimSun;"><br ></span></div><div  style="margin:14.0px 40.0px;"><div  style="clear:both;">------------------------------------------------------------------</div><div  style="clear:both;">发件人:Alan Bateman <Alan.Bateman@oracle.com></div><div  style="clear:both;">发送时间:2024年6月22日(星期六) 17:22</div><div  style="clear:both;">收件人:masoud parvari<masoud.parvari@gmail.com>; "何品(虎鸣)"<hepin.p@alibaba-inc.com></div><div  style="clear:both;">抄 送:"loom-dev"<loom-dev@openjdk.org></div><div  style="clear:both;">主 题:Re: 回复:Virtual thread hang and all threads stop running on JDK21</div><div  style="clear:both;"><br ></div>

  On 22/06/2024 09:54, masoud parvari wrote:<br >
    <div  style="margin:14.0px 40.0px;">
      
      <div >In class loading/initialization cases, the
        underlying issue is that pinning happens because there are <span  class="gmail-il">native</span> <span  class="gmail-il">frames</span> in
        the stack, so replacing the synchronized with a j.u.c lock will
        still lead to the same issue.<br >
      </div>
      <br >
    </div>
    <br >
    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.<br >
    <br >
    -Alan<br >
  

</div></blockquote></div>