<div style="text-align: left; text-indent: 0px; font-family: -apple-system, "system-ui", system-ui, "PingFang SC", "Microsoft YaHei UI", "Microsoft YaHei", "Source Han Sans CN", "Noto Sans CJK SC", sans-serif; font-size: 14px; color: rgb(19, 24, 29); line-height: 1.43;">thanks for your response.</div><div style="text-align: left; text-indent: 0px; font-family: -apple-system, "system-ui", system-ui, "PingFang SC", "Microsoft YaHei UI", "Microsoft YaHei", "Source Han Sans CN", "Noto Sans CJK SC", sans-serif; font-size: 14px; color: rgb(19, 24, 29); line-height: 1.43;"><br  /></div><div style="text-align: left; text-indent: 0px; font-family: -apple-system, "system-ui", system-ui, "PingFang SC", "Microsoft YaHei UI", "Microsoft YaHei", "Source Han Sans CN", "Noto Sans CJK SC", sans-serif; font-size: 14px; color: rgb(19, 24, 29); line-height: 1.43;">did you run the code by debug? </div><div style="text-align: left; text-indent: 0px; font-family: -apple-system, "system-ui", system-ui, "PingFang SC", "Microsoft YaHei UI", "Microsoft YaHei", "Source Han Sans CN", "Noto Sans CJK SC", sans-serif; font-size: 14px; color: rgb(19, 24, 29); line-height: 1.43;"><br  /></div><div style="text-align: left; text-indent: 0px; font-family: -apple-system, "system-ui", system-ui, "PingFang SC", "Microsoft YaHei UI", "Microsoft YaHei", "Source Han Sans CN", "Noto Sans CJK SC", sans-serif; font-size: 14px; color: rgb(19, 24, 29); line-height: 1.43;">The probability of this happening is very small,We need to use debug to reproduce it , and step by step as I mentioned in my previous email.</div><div style="text-align: left; text-indent: 0px; font-family: -apple-system, "system-ui", system-ui, "PingFang SC", "Microsoft YaHei UI", "Microsoft YaHei", "Source Han Sans CN", "Noto Sans CJK SC", sans-serif; font-size: 14px; color: rgb(19, 24, 29); line-height: 1.43;"><br  /></div><div style="text-align: left; text-indent: 0px; font-family: -apple-system, "system-ui", system-ui, "PingFang SC", "Microsoft YaHei UI", "Microsoft YaHei", "Source Han Sans CN", "Noto Sans CJK SC", sans-serif; font-size: 14px; color: rgb(19, 24, 29); line-height: 1.43;">After careful consideration, I no longer believe that this is a bug. The author should have designed it this way, as the probability of this happening is very small and recoverable。</div><blockquote style="line-height: 1.43;"><pre style="margin: 0px;"><div style="text-align: left; text-indent: 0px; white-space: normal; font-size: 13px; color: rgb(19, 24, 29);"><span style="line-height: 1.5;"><br  /></span></div></pre><pre style="margin: 0px;"><div style="text-align: left; text-indent: 0px; font-size: 13px; color: rgb(19, 24, 29);"><span style="line-height: 1.5;"><code>Thanks,</code></span></div></pre><pre style="margin: 0px;"><div style="text-align: left; text-indent: 0px; font-size: 13px; color: rgb(19, 24, 29);"><span style="line-height: 1.5;"><code>Jia Xu</code></span></div></pre></blockquote><div style="font-family: -apple-system, system-ui; font-size: 14px; color: rgb(0, 0, 0); line-height: 1.43;"><br  /></div><div style="line-height: 1.43;"><br  /></div><div contenteditable="false"><div style="display:block;width:150px;height:1px;border:none;margin:32px 0px 10px;background:rgb(230, 232, 235)"></div><div><a target="_blank" href="https://wx.mail.qq.com/home/index?t=readmail_businesscard_midpage&nocheck=true&name=%E5%BE%90%E4%BD%B3&icon=https%3A%2F%2Fthirdqq.qlogo.cn%2Fg%3Fb%3Doidb%26k%3DITa58KjAzQ2Sy661ARGMag%26s%3D0&mail=75317544%40qq.com&code=H4Xp95jU69bumCVa-cpoavrw-awZADI7ROSGBp3iiU4b3gIs06vTidmgHUdiv7EM3yZN-tUDAmV8dWTY35KR5g" style="text-decoration: underline;display:inline-block;text-decoration:none !important;font-family:-apple-system,BlinkMacSystemFont,PingFang SC,Microsoft YaHei" class="xm_write_card"><table cellspacing="0" cellpadding="0" style="table-layout:fixed;padding-right:20px"><tbody><tr valign="top"><td style="width:40px;min-width:40px;padding-top:10px"><div style="width:38px;height:38px;border:1px #FFF solid;border-radius:50%;margin:0;vertical-align:top;box-shadow:0 0 10px 0 rgba(127,152,178,0.14)"><img style="vertical-align: bottom;width:100%;height:100%;border-radius:50%;pointer-events:none" src="https://thirdqq.qlogo.cn/g?b=oidb&k=ITa58KjAzQ2Sy661ARGMag&s=0"  /></div></td><td style="padding:10px 0 8px 10px"><div style="font-size:14px;color:#33312E;line-height:20px;padding-bottom:2px;margin:0;font-weight:500" class="businessCard_name">徐佳</div><div style="font-size:12px;color:#999896;line-height:18px;margin:0" class="businessCard_mail">75317544@qq.com</div></td></tr></tbody></table></a></div></div>
      
<div style="line-height: 1.43;"><br  /></div><div style="line-height: 1.43;"><br  /></div><article style="line-height: 1.43;"><div style="display:flex;align-items:center;padding-top:8px" contenteditable="false">
        <div style="color:#959DA6;font-size:12px;line-height:30px">原始邮件</div>
        <hr style="border: none;flex-grow:1;border-top:1px solid rgba(21, 46, 74, 0.07);margin-left:8px"  />
      </div><table data-uneditable="true" style="line-height: 20px; border-radius: 6px; background-color: rgba(20, 46, 77, 0.05); margin: 0px; width: 100%;"><tbody><tr><td style="line-height: 20px; padding: 8px;"><div style="line-height: 20px; font-size: 12px;"><span style="color: rgb(92, 97, 102);">发件人:</span><span style="color: rgb(0, 0, 0);">Viktor Klang</span> <span style="color: rgb(149, 157, 166);"><viktor.klang@oracle.com></span></div><div style="line-height: 20px; font-size: 12px;"><span style="color: rgb(92, 97, 102);">发件时间:</span><span style="color: rgb(0, 0, 0);">2025年10月23日 18:27</span></div><div style="line-height: 20px; font-size: 12px;"><span style="color: rgb(92, 97, 102);">收件人:</span><span style="color: rgb(0, 0, 0);">Joe Darcy</span> <span style="color: rgb(149, 157, 166);"><joe.darcy@oracle.com>, </span><span style="color: rgb(0, 0, 0);">徐佳</span> <span style="color: rgb(149, 157, 166);"><75317544@qq.com>, </span><span style="color: rgb(0, 0, 0);">core-libs-dev</span> <span style="color: rgb(149, 157, 166);"><core-libs-dev@openjdk.org></span></div><div style="line-height: 20px; font-size: 12px;"><span style="color: rgb(92, 97, 102);">主题:</span><span style="color: rgb(0, 0, 0);">Re: ForkJoinPool of JDK21 : Despite having an idle worker, thesubmitted task did not run</span></div></td></tr></tbody></table><div><br  /></div><div style="line-height: normal; margin: 0px; font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Also, this doesn't reproduce for me.<br  />
<br  />
<b>/Library/Java/JavaVirtualMachines/jdk-21.jdk/Contents/Home/bin/java -version</b></div><div style="line-height: normal; margin: 0px; font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
java version "21.0.8" 2025-07-15 LTS</div><div style="line-height: normal; margin: 0px; font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Java(TM) SE Runtime Environment (build 21.0.8+12-LTS-250)</div><div style="line-height: normal; margin: 0px; font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Java HotSpot(TM) 64-Bit Server VM (build 21.0.8+12-LTS-250, mixed mode, sharing)</div><div style="line-height: normal; margin: 0px; min-height: 14px; font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
                                                                                                                                                                                                                                                          </div><div style="line-height: normal; margin: 0px; min-height: 14px; font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);"><br  />
</div><div style="line-height: normal; margin: 0px; font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);"><b>/Library/Java/JavaVirtualMachines/jdk-21.jdk/Contents/Home/bin/java ~/Desktop/ForkJoinPoolTest.java </b></div><div style="line-height: normal; margin: 0px; font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
===================</div><div style="line-height: normal; margin: 0px; font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
submited task1</div><div style="line-height: normal; margin: 0px; font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
QueuedSubmissionCount:1</div><div style="line-height: normal; margin: 0px; font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
ActiveThreadCount:2</div><div style="line-height: normal; margin: 0px; font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
PoolSize:2</div><div style="line-height: normal; margin: 0px; font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
===================</div><div style="line-height: normal; margin: 0px; font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
ForkJoinPool-1-worker-2 : finished task1</div><div style="line-height: normal; margin: 0px; font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
submited task2</div><div style="line-height: normal; margin: 0px; font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
ForkJoinPool-1-worker-2 : finished task2</div><div style="line-height: normal; margin: 0px; font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
===================</div><div style="line-height: normal; margin: 0px; font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
QueuedSubmissionCount:0</div><div style="line-height: normal; margin: 0px; font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
ActiveThreadCount:1</div><div style="line-height: normal; margin: 0px; font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
PoolSize:2</div><div style="line-height: normal; margin: 0px; font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
===================</div><div style="line-height: normal; margin: 0px; font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
===================</div><div style="line-height: normal; margin: 0px; font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
QueuedSubmissionCount:0</div><div style="line-height: normal; margin: 0px; font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
ActiveThreadCount:1</div><div style="line-height: normal; margin: 0px; font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
PoolSize:2</div><div style="line-height: normal; margin: 0px; font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
===================</div><div style="line-height: normal; margin: 0px; font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
^C%            </div><div style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);"><br  />
</div><div id="Signature"><div style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);"><br  />
</div><div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Cheers,<br  />
√</div><div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);"><br  />
</div><div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);"><b><br  />
</b></div><div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);"><b>Viktor Klang</b></div><div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Software Architect, Java Platform Group<br  />
Oracle</div></div><div id="appendonsend"></div><hr style="border: none;display: inline-block; width: 98%;"  /><div id="divRplyFwdMsg"><div style="direction: ltr;"><span style="font-family: Calibri, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);"><b>From:</b> core-libs-dev <core-libs-dev-retn@openjdk.org> on behalf of Joseph D. Darcy <joe.darcy@oracle.com><br  />
<b>Sent:</b> Thursday, 23 October 2025 01:02<br  />
<b>To:</b> 徐佳 <75317544@qq.com>; core-libs-dev <core-libs-dev@openjdk.org><br  />
<b>Subject:</b> Re: ForkJoinPool of JDK21 : Despite having an idle worker, the submitted task did not run</span>
</div><div style="direction: ltr;"> </div></div><div>Jia Xu, this mailing list is not a forum to submit bugs.<br  />
<br  />
From <a href="https://openjdk.org/guide/#jbs---jdk-bug-system" class="x_moz-txt-link-freetext" style="text-decoration: underline;">
https://openjdk.org/guide/#jbs---jdk-bug-system</a>, if you don't have a JBS account, you can submit bugs at
<a href="https://bugreport.java.com/bugreport/" class="x_moz-txt-link-freetext" style="text-decoration: underline;">https://bugreport.java.com/bugreport/</a></div><div><br  />
</div><div>Regards,</div><div><br  />
</div><div>-Joe</div><div><br  />
</div><div>On 10/22/2025 3:45 PM, 徐佳 wrote:<br  />
</div><blockquote><div style="font-size: 13px;">Hi,</div><pre style="margin-top: 0px; margin-bottom: 0px;"><div><span style="line-height: 1.5;"><code>Despite having an idle worker, the submitted task did not run.</code></span></div></pre><pre style="margin-top: 0px; margin-bottom: 0px;"><div>Steps to reproduce:</div></pre><pre style="margin-top: 0px; margin-bottom: 0px;"><div style="font-size: 13px;"><span style="line-height: 1.5;"><code>-------------------</code></span></div></pre><pre style="margin-top: 0px; margin-bottom: 0px;"><div style="font-size: 13px;"><span style="line-height: 1.5;"><code>1. before all , add a breakpoint on the 1864th line of ForkJoinPool source code in awaitWork method.</code></span></div></pre><pre style="margin-top: 0px; margin-bottom: 0px;"><div><span style="font-size: 13px; line-height: 1.5;"><code>2. then debug the following code,and a thread will be </code></span>paused at breakpoint</div></pre><pre style="margin-top: 0px; margin-bottom: 0px;"><div><span style="font-size: 13px; line-height: 1.5;"><code>3. after "</code></span>submited task2" printed in the console<span style="font-size: 12px; color: rgb(69, 69, 69);">, </span>resume the breakpoint.</div></pre><pre style="margin-top: 0px; margin-bottom: 0px;"><div>4. Despite having an idle worker, task2 did not run.</div></pre><pre style="margin-top: 0px; margin-bottom: 0px;"><p style="line-height: normal; white-space: normal; margin: 0px; font-size: 12px; color: rgb(69, 69, 69);"><span style="line-height: 1.5;"><b><code>public</code></b><code> </code><b><code>class</code></b><code> ForkJoinPoolTest {</code></span></p><p style="line-height: normal; white-space: normal; margin: 0px; font-size: 12px; color: rgb(69, 69, 69);"><span style="line-height: 1.5;"><b><code>public</code></b><code> </code><b><code>static</code></b><code> </code><b><code>void</code></b><code> main</code></span><span style="line-height: normal;"><code>(</code></span><span style="line-height: 1.5;"><code>String</code></span><span style="line-height: normal;"><code>[]</code></span><span style="line-height: 1.5;"><code> args</code></span><span style="line-height: normal;"><code>)</code></span><span style="line-height: 1.5;"><code> </code><b><code>throws</code></b><code> InterruptedException {</code></span></p><p style="line-height: normal; white-space: normal; margin: 0px; font-size: 12px; color: rgb(69, 69, 69);"><span style="line-height: 1.5;"><code>//Add a breakpoint on the 1864th line of ForkJoinPool source code in awaitWork method.</code></span></p><p style="line-height: normal; white-space: normal; margin: 0px; min-height: 14px; font-size: 12px; color: rgb(69, 69, 69);"><span style="line-height: 1.5;"><code><
 span class="Apple-tab-span" style="white-space: pre;">  </code></span></p><p style="line-height: normal; white-space: normal; margin: 0px; font-size: 12px; color: rgb(69, 69, 69);"><span style="line-height: 1.5;"><code>ForkJoinPool pool = </code><b><code>new</code></b><code> ForkJoinPool</code></span><span style="line-height: normal;"><code>(</code></span><span style="line-height: 1.5;"><code>2</code></span><span style="line-height: normal;"><code>);</code></span><span style="line-height: 1.5;"><code>//total 2 Threads</code></span></p><p style="line-height: normal; white-space: normal; margin: 0px; font-size: 12px; color: rgb(69, 69, 69);"><span style="line-height: 1.5;"><code>//create worker w1</code></span><span style="line-height: normal;"><code>,</code></span><span style="line-height: 1.5;"><code> keep running and printing pool information</code></span></p><p style="line-height: normal; white-space: normal; margin: 0px; font-size: 12px; color: rgb(69, 69, 69);"><span style="line-height: 1.5;"><code>pool.submit</code></span><span style="line-height: normal;"><code>(()</code></span><span style="line-height: 1.5;"><code> -> {</code></span></p><p style="line-height: normal; white-space: normal; margin: 0px; font-size: 12px; color: rgb(69, 69, 69);"><span style="line-height: 1.5;"><b><code>while</code></b></span><span style="line-height: normal;"><code>(</code></span><span style="line-height: 1.5;"><b><code>true</code></b></span><span style="line-height: normal;"><code>)</code></span><span style="line-height: 1.5;"><code> {</code></span></p><p style="line-height: normal; white-space: normal; margin: 0px; font-size: 12px; color: rgb(69, 69, 69);"><span style="line-height: 1.5;"><code>System.</code><b><i><code>err</code></i></b><code>.println</code></span><span style="line-height: normal;"><code>(</code></span><span style="line-height: 1.5;"><code>"==================="</code></span><span style="line-height: normal;"><code>);</code></span></p><p style="line-height: normal; white-space: normal; margin: 0px; color: rgb(69, 69, 69);"><span style="font-size: 13px; line-height: 1.5;"><code>System.</code><b><i><code>err</code></i></b><code>.println</code></span><span style="font-size: 13px; line-height: normal;"><code>(</code></span><span style="font-size: 13px; line-height: 1.5;"><code>"QueuedSubmissionCount:" + pool.getQueuedSubmissionCount());</code></span></p><p style="line-height: normal; white-space: normal; margin: 0px; font-size: 12px; color: rgb(69, 69, 69);"><span style="line-height: 1.5;"><code>System.</code><b><i><code>err</code></i></b><code>.println</code></span><span style="line-height: normal;"><code>(</code></span><span style="line-height: 1.5;"><code>"ActiveThreadCount:" + pool.getActiv
 eThreadCount</code></span><span style="line-height: normal;"><code>());</code></span></p><p style="line-height: normal; white-space: normal; margin: 0px; font-size: 12px; color: rgb(69, 69, 69);"><span style="line-height: 1.5;"><code>System.</code><b><i><code>err</code></i></b><code>.println</code></span><span style="line-height: normal;"><code>(</code></span><span style="line-height: 1.5;"><code>"PoolSize:" + pool.getPoolSize</code></span><span style="line-height: normal;"><code>());</code></span></p><p style="line-height: normal; white-space: normal; margin: 0px; font-size: 12px; color: rgb(69, 69, 69);"><span style="line-height: 1.5;"><code>System.</code><b><i><code>err</code></i></b><code>.println</code></span><span style="line-height: normal;"><code>(</code></span><span style="line-height: 1.5;"><code>"==================="</code></span><span style="line-height: normal;"><code>);</code></span></p><p style="line-height: normal; white-space: normal; margin: 0px; font-size: 12px; color: rgb(69, 69, 69);"><span style="line-height: 1.5;"><code>LockSupport.</code><i><code>parkNanos</code></i></span><span style="line-height: normal;"><code>(</code></span><span style="line-height: 1.5;"><code>5 * 1000_000_000L</code></span><span style="line-height: normal;"><code>);</code></span><span style="line-height: 1.5;"><code>//5s</code></span></p><p style="line-height: normal; white-space: normal; margin: 0px; font-size: 12px; color: rgb(69, 69, 69);"><span style="line-height: 1.5;"><code>}</code></span></p><p style="line-height: normal; white-space: normal; margin: 0px; font-size: 12px; color: rgb(69, 69, 69);"><span style="line-height: 1.5;"><code>});</code></span></p><p style="line-height: normal; white-space: normal; margin: 0px; font-size: 12px; color: rgb(69, 69, 69);"><span style="line-height: 1.5;"><code>//create another worker w2</code></span></p><p style="line-height: normal; white-space: normal; margin: 0px; font-size: 12px; color: rgb(69, 69, 69);"><span style="line-height: 1.5;"><code>pool.submit</code></span><span style="line-height: normal;"><code>(()</code></span><span style="line-height: 1.5;"><code> -> System.</code><b><i><code>out</code></i></b><code>.println</code></span><span style="line-height: normal;"><code>(</code></span><span style="line-height: 1.5;"><code>Thread.</code><i><code>currentThread</code></i></span><span style="line-height: normal;"><code>()</code></span><span style="line-height: 1.5;"><code>.getName</code></span><span style="line-height: normal;"><code>()</code></span><span style="line-height: 1.5;"><code> + " : finished task1"</code></span><span style="line-height: normal;"><code>));</code></span></p><p style="line-height: normal; white-space: normal; margin: 0px; font-size: 12px; color: rgb(69, 69, 69);"><span style="line-height: 1.5;"><code>System.</code><b><i><code>out</code></i></b><code>.println</code></span><span style="line-height: normal;"><code>(</code></span><span style="line-height: 1.5;"><code>"submited task1"</code></span><span style="line-height: normal;"><code>);</code></span></p><p style="line-height: normal; white-space: normal; margin: 0px; font-size: 12px; color: rgb(69, 69, 69);"><span style="line-height: 1.5;"><code>Thread.</code><i><code>sleep</code></i></span><span style="line-height: normal;"><code>(</code></span><span style="line-height: 1.5;"><code>3 * 1000</code></span><span style="line-height: normal;"><code>);</code></span><span style="line-height: 1.5;"><code>// waiting for task1 to end</code></span></p><p style="line-height: normal; white-space: normal; margin: 0px; font-size: 12px; color: rgb(69, 69, 69);"><span style="line-height: 1.5;"><code>//now task1 finished and no task in queue</code></span><span style="line-height: normal;"><code>,</code></span><span style="line-height: 1.5;"><code> w2 is pausing at breakpoint in  awaitWork method.</code></span></p><p style="line-height: normal; white-space: normal; margin: 0px; font-size: 12px; color: rgb(69, 69, 69);"><span style="line-height: 1.5;"><code>pool.submit</code></span><span style="line-height: normal;"><code>(()</code></span><span style="line-height: 1.5;"><code> -> System.</code><b><i><code>out</code></i></b><code>.println</code></span><span style="line-height: normal;"><code>(</code></span><span style="line-height: 1.5;"><code>Thread.</code><i><code>currentThread</code></i></span><span style="line-height: normal;"><code>()</code></span><span style="line-height: 1.5;"><code>.getName</code></span><span style="line-height: normal;"><code>()</code></span><span style="line-height: 1.5;"><code> + " : fin
 ished task2"</code></span><span style="line-height: normal;"><code>));</code></span></p><p style="line-height: normal; white-space: normal; margin: 0px; font-size: 12px; color: rgb(69, 69, 69);"><span style="line-height: 1.5;"><code>System.</code><b><i><code>out</code></i></b><code>.println</code></span><span style="line-height: normal;"><code>(</code></span><span style="line-height: 1.5;"><code>"submited task2"</code></span><span style="line-height: normal;"><code>);</code></span></p><p style="line-height: normal; white-space: normal; margin: 0px; font-size: 12px; color: rgb(69, 69, 69);"><span style="line-height: 1.5;"><code>//after submitted task2</code></span><span style="line-height: normal;"><code>,</code></span><span style="line-height: 1.5;"><code> resume w2 </code></span><span style="line-height: normal;"><code>,</code></span><span style="line-height: 1.5;"><code> and then w2 will park on line 1891 </code></span><span style="line-height: normal;"><code>,</code></span><span style="line-height: 1.5;"><code>although there is still task2 in the Submission queue </code></span></p><p style="line-height: normal; white-space: normal; margin: 0px; font-size: 12px; color: rgb(69, 69, 69);"><span style="line-height: 1.5;"><code>//if no new task submitted</code></span><span style="line-height: normal;"><code>,</code></span><span style="line-height: 1.5;"><code> task2 will not run.</code></span></p><p style="line-height: normal; white-space: normal; margin: 0px; font-size: 12px; color: rgb(69, 69, 69);"><span style="line-height: 1.5;"><code>Thread.</code><i><code>sleep</code></i></span><span style="line-height: normal;"><code>(</code></span><span style="line-height: 1.5;"><code>5 * 60 * 1000</code></span><span style="line-height: normal;"><code>);</code></span></p><p style="line-height: normal; white-space: normal; margin: 0px; font-size: 12px; color: rgb(69, 69, 69);"><span style="line-height: 1.5;"><code>pool.close</code></span><span style="line-height: normal;"><code>();</code></span></p><p style="line-height: normal; white-space: normal; margin: 0px; font-size: 12px; color: rgb(69, 69, 69);"><span style="line-height: 1.5;"><code>}</code></span></p><p style="line-height: normal; white-space: normal; margin: 0px; font-size: 12px; color: rgb(69, 69, 69);"><span style="line-height: 1.5;"><code>}</code></span></p><pre style="margin-top: 0px; margin-bottom: 0px;"><div style="font-size: 13px;"><span style="line-height: 1.5;"><code>
</code></span></div></pre><div style="font-size: 13px;"><span style="line-height: 1.5;"><code>result:</code></span></div></pre><pre style="margin-top: 0px; margin-bottom: 0px;"><div style="font-size: 13px;"><span style="line-height: 1.5;"><code>
<img src="cid:F8FE61C2@8FD16500.0825FA6800000000.jpg" id="x_img_insert_1761144985303033518428439668657" data-outlook-trace="F:1|T:1" width="339" height="388" style="vertical-align: bottom;width: 339px; height: 388px;"  />


Environment:
------------
</code></span></div><p style="line-height: normal; white-space: normal; margin: 0px; font-family: Menlo; font-size: 11px;"><span style="line-height: 1.5;"><code>java version "21.0.8" 2025-07-15 LTS</code></span></p><p style="line-height: normal; white-space: normal; margin: 0px; font-family: Menlo; font-size: 11px;"><span style="line-height: 1.5;"><code>Java(TM) SE Runtime Environment (build 21.0.8+12-LTS-250)</code></span></p><p style="line-height: normal; white-space: normal; margin: 0px; font-family: Menlo; font-size: 11px;"><span style="line-height: 1.5;"><code>Java HotSpot(TM) 64-Bit Server VM (build 21.0.8+12-LTS-250, mixed mode, sharing)</code></span></p><div style="font-size: 13px;"><span style="line-height: 1.5;"><code>it seams that a task submitted between method “scan”and “awaitWork” may not be executed immediately</code></span></div></pre><pre style="margin-top: 0px; margin-bottom: 0px;"><div><span style="font-size: 13px; line-height: 1.5;"><code>I think the reason is that the worker did not recheck the waiting condition "</code></span>hasTasks<span style="font-size: 13px; line-height: 1.5;"><code>" between "</code></span>enqueue<span style="font-size: 13px; line-height: 1.5;"><code>" and "</code></span>park"</div></pre><pre style="margin-top: 0px; margin-bottom: 0px;"><div>I don't know whether this is a bug or it's just designed this way</div></pre><pre style="margin-top: 0px; margin-bottom: 0px;"><div style="font-size: 13px;"><span style="line-height: 1.5;"><code>
Please let me know if more information is needed.

Thanks,
Jia Xu</code></span></div></pre><hr align="left" style="border: none;line-height: 0; margin: 0px 0px 10px; padding-top: 20px; border-bottom: 1px solid rgb(228, 229, 230); width: 50px; height: 0px;"  /><table cellspacing="0" cellpadding="0" style="table-layout: fixed; box-sizing: border-box; border-collapse: collapse; border-spacing: 0px;"><tbody><tr><td style="padding-top: 10px; width: 40px; min-width: 40px;"><div style="margin: 0px; border-width: 1px; border-style: solid; border-color: rgb(255, 255, 255); border-radius: 50%; font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei"; font-size: 14px; color: rgb(0, 0, 0);"><a href="https://wx.mail.qq.com/home/index?t=readmail_businesscard_midpage&nocheck=true&name=%E5%BE%90%E4%BD%B3&icon=https%3A%2F%2Fthirdqq.qlogo.cn%2Fg%3Fb%3Doidb%26k%3DITa58KjAzQ2Sy661ARGMag%26s%3D0&mail=75317544%40qq.com&code=ovqAUzHwnHYC7-bg8gt5zIWB5w7lrIw4naNXXN4i8PT0cdk69vq9G4d0D9uz44QQxBxJAXH7CqfvaQpIQtyFFA" target="_blank" id="x_in_alias" class="x_xm_write_card" style="text-decoration: underline;text-decoration: none; display: inline-block;"><img src="https://thirdqq.qlogo.cn/g?b=oidb&k=ITa58KjAzQ2Sy661ARGMag&s=0" style="vertical-align: bottom;width: 100%; border-radius: 50%;"  /></a></div></td><td style="padding-top: 10px; padding-bottom: 8px; padding-left: 10px;"><div style="line-height: 20px; margin: 0px; padding-bottom: 2px; font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei"; font-size: 14px; color: rgb(51, 49, 46);"><span style="font-weight: 500;"><a href="https://wx.mail.qq.com/home/index?t=readmail_businesscard_midpage&nocheck=true&name=%E5%BE%90%E4%BD%B3&icon=https%3A%2F%2Fthirdqq.qlogo.cn%2Fg%3Fb%3Doidb%26k%3DITa58KjAzQ2Sy661ARGMag%26s%3D0&mail=75317544%40qq.com&code=ovqAUzHwnHYC7-bg8gt5zIWB5w7lrIw4naNXXN4i8PT0cdk69vq9G4d0D9uz44QQxBxJAXH7CqfvaQpIQtyFFA" target="_blank" id="x_in_alias" class="x_xm_write_card" style="text-decoration: underline;text-decoration: none; display: inline-block;">
徐佳</a></span></div><div style="line-height: 18px; margin: 0px; font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei"; font-size: 12px; color: rgb(153, 152, 150);"><a href="https://wx.mail.qq.com/home/index?t=readmail_businesscard_midpage&nocheck=true&name=%E5%BE%90%E4%BD%B3&icon=https%3A%2F%2Fthirdqq.qlogo.cn%2Fg%3Fb%3Doidb%26k%3DITa58KjAzQ2Sy661ARGMag%26s%3D0&mail=75317544%40qq.com&code=ovqAUzHwnHYC7-bg8gt5zIWB5w7lrIw4naNXXN4i8PT0cdk69vq9G4d0D9uz44QQxBxJAXH7CqfvaQpIQtyFFA" target="_blank" id="x_in_alias" class="x_xm_write_card" style="text-decoration: underline;text-decoration: none; display: inline-block;">
75317544@qq.com</a></div></td></tr></tbody></table><div> </div></blockquote><p style="margin-top: 0px; margin-bottom: 0px;"><br  />
</p></article><div style="line-height: 1.43;"><br  /></div>