<!DOCTYPE html><html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
On 05/06/2024 10:37, 何品(虎鸣) wrote:<br>
<blockquote type="cite" cite="mid:b42ded56-d92e-4272-9f34-3485e18401b3.hepin.p@alibaba-inc.com">
<div class="__aliyun_email_body_block">
<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 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 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 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>
</blockquote>
<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/">https://jdk.java.net/loom/</a><br>
</body>
</html>