<!DOCTYPE html><html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
On 22/07/2024 07:09, Yuval Lombard wrote:<br>
<blockquote type="cite" cite="mid:CAAKnT1czo68uGqyWafqu1-RX6W3pFVHfQW-CYV3=K2aSHz4hSQ@mail.gmail.com">
<div dir="ltr">Hi Alan,<br>
<br>
Thanks for the clarifications!<br>
OK regarding the pooling of the VT, now I understand what robert
meant about the partial code example.<br>
<br>
The scheduler is created in this way:<br>
<span style="padding:0px 2px"><span style="padding:0px 2px"><span style="color:rgb(0,0,0);font-family:Consolas;font-size:10pt;white-space:pre">ScheduledExecutorService <span style="color:rgb(106,62,62)">scheduler = </span></span></span><span style="color:rgb(0,0,0);font-family:Consolas;font-size:10pt;white-space:pre">Executors.<span style="font-style:italic">newScheduledThreadPool</span>(1)
</span></span><br>
<div>then as the code example shows after it is granted with a
permit to execute a task, it delegates it to the VT by
starting it this way:<br>
<span style="padding:0px 2px"><span style="color:rgb(0,0,0);font-family:Consolas;font-size:10pt;white-space:pre">Thread.<span style="font-style:italic">ofVirtual</span>().start(() -> { ... }</span></span><br>
</div>
</div>
</blockquote>
<br>
I read Robert's mail as a comment on the code fragment in your first
mail. The finally block in that code fragment releases a permit
unconditionally whereas I assume you only want to release if
acquired in that thread.<br>
<br>
My comment is about thread dump you attached. Look at threads #73,
#77 and #83 as examples. The stack traces suggests a SPTE using
virtual threads as worker threads. It's nothing to do with the issue
we are discussing here, just a comment that on a something
surprising that you might want to look into.<br>
<br>
<blockquote type="cite" cite="mid:CAAKnT1czo68uGqyWafqu1-RX6W3pFVHfQW-CYV3=K2aSHz4hSQ@mail.gmail.com">
<div dir="ltr">
<div><span style="padding:0px 2px"><span style="color:rgb(0,0,0);font-family:Consolas;font-size:10pt;white-space:pre">
</span></span></div>
<div>I upgrade the jdk to the latest EA and test it again, and
get back to you in any case with the relevant thread dumps.<br>
</div>
</div>
<br>
</blockquote>
Thanks. As I mentioned, I think this is related to preemption when
cancelling a timer after Object.wait(millis). We may have to publish
a new EA build.<br>
<br>
-Alan<br>
</body>
</html>