[External] : Re: ForkJoinPool of JDK21 : Despite having an idle worker, thesubmitted task did not run

Viktor Klang viktor.klang at oracle.com
Thu Oct 23 14:49:16 UTC 2025


Hi,

A reproducer which requires breakpoints and debuggers will not be practical to try to fashion a regression test after, unfortunately.
If you're able to create a reproducer (even if it requires many iterations), please share.

Cheers,
¡Ì


Viktor Klang
Software Architect, Java Platform Group
Oracle

Confidential ¨C Oracle Internal
________________________________
From: Ðì¼Ñ <75317544 at qq.com>
Sent: Thursday, 23 October 2025 14:52
To: Viktor Klang <viktor.klang at oracle.com>; Joe Darcy <joe.darcy at oracle.com>; core-libs-dev <core-libs-dev at openjdk.org>
Subject: [External] : Re: ForkJoinPool of JDK21 : Despite having an idle worker, thesubmitted task did not run

thanks for your response.

did you run the code by debug£¿

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.

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¡£


Thanks,

Jia Xu


<https://urldefense.com/v3/__https://wx.mail.qq.com/home/index?t=readmail_businesscard_midpage&nocheck=true&name=**E&icon=https*3A*2F*2Fthirdqq.qlogo.cn*2Fg*3Fb*3Doidb*26k*3DITa58KjAzQ2Sy661ARGMag*26s*3D0&mail=75317544*40qq.com&code=H4Xp95jU69bumCVa-cpoavrw-awZADI7ROSGBp3iiU4b3gIs06vTidmgHUdiv7EM3yZN-tUDAmV8dWTY35KR5g__;5b6Q5L2zJSUlJSUlJSUlJSU!!ACWV5N9M2RV99hQ!Pu1K5WZbNoapUo15ono9LryUKTm-QxtiLinbI9XSEnlfm3nQNo6Ryv-VYHFClMbO6AbQ7qCEvHnkHg0Brw$>
[https://thirdqq.qlogo.cn/g?b=oidb&k=ITa58KjAzQ2Sy661ARGMag&s=0]
Ðì¼Ñ
75317544 at qq.com


ԭʼÓʼþ
________________________________
·¢¼þÈË£ºViktor Klang <viktor.klang at oracle.com>
·¢¼þʱ¼ä£º2025Äê10ÔÂ23ÈÕ 18:27
ÊÕ¼þÈË£ºJoe Darcy <joe.darcy at oracle.com>, Ðì¼Ñ <75317544 at qq.com>, core-libs-dev <core-libs-dev at openjdk.org>
Ö÷Ì⣺Re: ForkJoinPool of JDK21 : Despite having an idle worker, thesubmitted task did not run

Also, this doesn't reproduce for me.

/Library/Java/JavaVirtualMachines/jdk-21.jdk/Contents/Home/bin/java -version
java version "21.0.8" 2025-07-15 LTS
Java(TM) SE Runtime Environment (build 21.0.8+12-LTS-250)
Java HotSpot(TM) 64-Bit Server VM (build 21.0.8+12-LTS-250, mixed mode, sharing)


/Library/Java/JavaVirtualMachines/jdk-21.jdk/Contents/Home/bin/java ~/Desktop/ForkJoinPoolTest.java
===================
submited task1
QueuedSubmissionCount:1
ActiveThreadCount:2
PoolSize:2
===================
ForkJoinPool-1-worker-2 : finished task1
submited task2
ForkJoinPool-1-worker-2 : finished task2
===================
QueuedSubmissionCount:0
ActiveThreadCount:1
PoolSize:2
===================
===================
QueuedSubmissionCount:0
ActiveThreadCount:1
PoolSize:2
===================
^C%


Cheers,
¡Ì


Viktor Klang
Software Architect, Java Platform Group
Oracle
________________________________
From: core-libs-dev <core-libs-dev-retn at openjdk.org> on behalf of Joseph D. Darcy <joe.darcy at oracle.com>
Sent: Thursday, 23 October 2025 01:02
To: Ðì¼Ñ <75317544 at qq.com>; core-libs-dev <core-libs-dev at openjdk.org>
Subject: Re: ForkJoinPool of JDK21 : Despite having an idle worker, the submitted task did not run

Jia Xu, this mailing list is not a forum to submit bugs.

From https://openjdk.org/guide/#jbs---jdk-bug-system, if you don't have a JBS account, you can submit bugs at https://bugreport.java.com/bugreport/<https://urldefense.com/v3/__https://bugreport.java.com/bugreport/__;!!ACWV5N9M2RV99hQ!Pu1K5WZbNoapUo15ono9LryUKTm-QxtiLinbI9XSEnlfm3nQNo6Ryv-VYHFClMbO6AbQ7qCEvHkEfjijTA$>

Regards,

-Joe

On 10/22/2025 3:45 PM, Ðì¼Ñ wrote:
Hi,

Despite having an idle worker, the submitted task did not run.

Steps to reproduce:

-------------------

1. before all , add a breakpoint on the 1864th line of ForkJoinPool source code in awaitWork method.

2. then debug the following code£¬and a thread will be paused at breakpoint

3. after "submited task2" printed in the console, resume the breakpoint.

4. Despite having an idle worker, task2 did not run.

public class ForkJoinPoolTest {

public static void main(String[] args) throws InterruptedException {

//Add a breakpoint on the 1864th line of ForkJoinPool source code in awaitWork method.

<
 span class="Apple-tab-span" style="white-space: pre;">

ForkJoinPool pool = new ForkJoinPool(2);//total 2 Threads

//create worker w1, keep running and printing pool information

pool.submit(() -> {

while(true) {

System.err.println("===================");

System.err.println("QueuedSubmissionCount:" + pool.getQueuedSubmissionCount());

System.err.println("ActiveThreadCount:" + pool.getActiv
 eThreadCount());

System.err.println("PoolSize:" + pool.getPoolSize());

System.err.println("===================");

LockSupport.parkNanos(5 * 1000_000_000L);//5s

}

});

//create another worker w2

pool.submit(() -> System.out.println(Thread.currentThread().getName() + " : finished task1"));

System.out.println("submited task1");

Thread.sleep(3 * 1000);// waiting for task1 to end

//now task1 finished and no task in queue, w2 is pausing at breakpoint in  awaitWork method.

pool.submit(() -> System.out.println(Thread.currentThread().getName() + " : fin
 ished task2"));

System.out.println("submited task2");

//after submitted task2, resume w2 , and then w2 will park on line 1891 ,although there is still task2 in the Submission queue

//if no new task submitted, task2 will not run.

Thread.sleep(5 * 60 * 1000);

pool.close();

}

}




result:


[cid:F8FE61C2 at 8FD16500.0825FA6800000000.jpg]


Environment:
------------


java version "21.0.8" 2025-07-15 LTS

Java(TM) SE Runtime Environment (build 21.0.8+12-LTS-250)

Java HotSpot(TM) 64-Bit Server VM (build 21.0.8+12-LTS-250, mixed mode, sharing)

it seams that a task submitted between method ¡°scan¡±and ¡°awaitWork¡± may not be executed immediately

I think the reason is that the worker did not recheck the waiting condition "hasTasks" between "enqueue" and "park"

I don't know whether this is a bug or it's just designed this way


Please let me know if more information is needed.

Thanks,
Jia Xu

________________________________
[https://thirdqq.qlogo.cn/g?b=oidb&k=ITa58KjAzQ2Sy661ARGMag&s=0]<https://urldefense.com/v3/__https://wx.mail.qq.com/home/index?t=readmail_businesscard_midpage&nocheck=true&name=**E&icon=https*3A*2F*2Fthirdqq.qlogo.cn*2Fg*3Fb*3Doidb*26k*3DITa58KjAzQ2Sy661ARGMag*26s*3D0&mail=75317544*40qq.com&code=ovqAUzHwnHYC7-bg8gt5zIWB5w7lrIw4naNXXN4i8PT0cdk69vq9G4d0D9uz44QQxBxJAXH7CqfvaQpIQtyFFA__;5b6Q5L2zJSUlJSUlJSUlJSU!!ACWV5N9M2RV99hQ!Pu1K5WZbNoapUo15ono9LryUKTm-QxtiLinbI9XSEnlfm3nQNo6Ryv-VYHFClMbO6AbQ7qCEvHkQ3r61-w$>
Ðì¼Ñ<https://urldefense.com/v3/__https://wx.mail.qq.com/home/index?t=readmail_businesscard_midpage&nocheck=true&name=**E&icon=https*3A*2F*2Fthirdqq.qlogo.cn*2Fg*3Fb*3Doidb*26k*3DITa58KjAzQ2Sy661ARGMag*26s*3D0&mail=75317544*40qq.com&code=ovqAUzHwnHYC7-bg8gt5zIWB5w7lrIw4naNXXN4i8PT0cdk69vq9G4d0D9uz44QQxBxJAXH7CqfvaQpIQtyFFA__;5b6Q5L2zJSUlJSUlJSUlJSU!!ACWV5N9M2RV99hQ!Pu1K5WZbNoapUo15ono9LryUKTm-QxtiLinbI9XSEnlfm3nQNo6Ryv-VYHFClMbO6AbQ7qCEvHkQ3r61-w$>
75317544 at qq.com<https://urldefense.com/v3/__https://wx.mail.qq.com/home/index?t=readmail_businesscard_midpage&nocheck=true&name=**E&icon=https*3A*2F*2Fthirdqq.qlogo.cn*2Fg*3Fb*3Doidb*26k*3DITa58KjAzQ2Sy661ARGMag*26s*3D0&mail=75317544*40qq.com&code=ovqAUzHwnHYC7-bg8gt5zIWB5w7lrIw4naNXXN4i8PT0cdk69vq9G4d0D9uz44QQxBxJAXH7CqfvaQpIQtyFFA__;5b6Q5L2zJSUlJSUlJSUlJSU!!ACWV5N9M2RV99hQ!Pu1K5WZbNoapUo15ono9LryUKTm-QxtiLinbI9XSEnlfm3nQNo6Ryv-VYHFClMbO6AbQ7qCEvHkQ3r61-w$>



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/core-libs-dev/attachments/20251023/b0220dc3/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: F8FE61C2 at 8FD16500.0825FA6800000000.jpg
Type: image/jpeg
Size: 155320 bytes
Desc: F8FE61C2 at 8FD16500.0825FA6800000000.jpg
URL: <https://mail.openjdk.org/pipermail/core-libs-dev/attachments/20251023/b0220dc3/F8FE61C28FD16500.0825FA6800000000-0001.jpg>


More information about the core-libs-dev mailing list