<div class="__aliyun_email_body_block"><div  style="clear:both;">Yes, even jcmd is hung, we are currently want to switch back to the forkJoinPool and increase the <span >jdk.virtualThreadScheduler.maxPoolSize and </span></div><div  style="clear:both;"><span  style="font-family:Tahoma,Arial,STHeiti,SimSun;"><span >jdk.virtualThreadScheduler.parallelism > our total max concurrency.</span></span></div><div  style="clear:both;"><span  style="font-family:Tahoma,Arial,STHeiti,SimSun;"><span ><br ></span></span></div><div  style="clear:both;"><span  style="font-family:Tahoma,Arial,STHeiti,SimSun;"><span >I have several system is using Virtual thread, but only this one cause problem. </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><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;">发件人:Alan Bateman <Alan.Bateman@oracle.com></div><div  style="clear:both;">发送时间:2024年6月5日(星期三) 18:00</div><div  style="clear:both;">收件人:"何品(虎鸣)"<hepin.p@alibaba-inc.com>; "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 05/06/2024 10:37, 何品(虎鸣) wrote:<br >
    <div >
      
      
        <div  style="clear:both;"><span  style="font-family:Tahoma,Arial,STHeiti,SimSun;">Thanks, </span></div>
        <div  style="clear:both;"><span  style="font-family:Tahoma,Arial,STHeiti,SimSun;">1. it hung
            when we are sharing the common usage of the Virtualthread
            (the default scheduler) cross two modules.</span></div>
        <div  style="clear:both;"><span  style="font-family:Tahoma,Arial,STHeiti,SimSun;">2. after
            that, I try to hack the virtual thread builder with
            separated ThreadPoolExecutor.</span></div>
        <div  style="clear:both;"><span  style="font-family:Tahoma,Arial,STHeiti,SimSun;">3. but
            still , it hung.</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;">when it
            hung, `<span  class=" __aliyun_node_has_color" style="color:#000000;font-family:Helvetica,Tahoma,Arial;font-size:14.0px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:.0px;text-transform:none;word-spacing:.0px;white-space:normal;text-decoration-thickness:initial;text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline;">jcmd
              Thread.print` prints nothing. and dump programly print
              nothing too.</span></span></div>
        <div  style="clear:both;"><span  class=" __aliyun_node_has_color" style="font-family:Helvetica,Tahoma,Arial;color:#000000;font-size:14.0px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:.0px;text-transform:none;word-spacing:.0px;white-space:normal;text-decoration-thickness:initial;text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline;"><br >
          </span></div>
        <div  style="clear:both;"><span  class=" __aliyun_node_has_color" style="font-family:Helvetica,Tahoma,Arial;color:#000000;font-size:14.0px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:.0px;text-transform:none;word-spacing:.0px;white-space:normal;text-decoration-thickness:initial;text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline;">After
            switch back to normal thread, it never hang.</span></div>
        <div  style="clear:both;"><span  style="font-family:Helvetica,Tahoma,Arial;">Some
            information:<br >
            module A is using `Object.notifyAll, Object.wait` and module
            B is using `CompletableFuture.get` (may > 100 times in
            one rune)</span></div>
        <div  style="clear:both;"><span  style="font-family:Helvetica,Tahoma,Arial;">I was thinking
            if that could be a problem of notification missing, where in
            Module A, the concurrency is 3000, protected by a <span >semaphore,
              but the underling Carrier Thread is only 128, and 3000
              > 128. </span></span><br >
        </div>
      
    </div>
    <br >
    If it's using synchronized/Object.wait then this may be related to
    pinning. When there is both object monitors and j.u.concurrent locks
    in play then it's possible to create deadlock scenarios due to
    starvation, or selecting a successor or thread to wakeup and the
    thread can't continue because there are no carriers available.
    Object.wait will temporarily increase parallelism to smooth and help
    some cases but it may not help you here, and does nothing when the
    scheduler has been changed to be something other than a ForkJoinPool
    instance.<br >
    <br >
    When you say "prints nothing" then you mean this literally or do you
    mean that jcmd is hung too? If so that's a hint that may be the lock
    for standard output is held by a virtual thread that can't continue
    because there are no carriers available.<br >
    <br >
    It would be interesting to try the latest Loom EA builds which has
    changes to the object monitor implementation that doesn't pin. Would
    you have time to try these builds out?<br >
    <br >
    -Alan<br >
    <br >
    [1] <a  class="moz-txt-link-freetext" href="https://jdk.java.net/loom/" target="_blank">https://jdk.java.net/loom/</a><br >
  

</blockquote></div>