RFR: 8373118: Test java/lang/Thread/virtual/Starvation.java timed out
Viktor Klang
vklang at openjdk.org
Fri Dec 12 23:05:04 UTC 2025
On Fri, 12 Dec 2025 16:44:21 GMT, Doug Lea <dl at openjdk.org> wrote:
> Changes signal filtering to avoid possible starvation
src/java.base/share/classes/java/util/concurrent/ForkJoinPool.java line 1435:
> 1433: int fifo, int qbase) {
> 1434: int stolen = 1;
> 1435: if (task != null && q != null) {
Suggestion:
if (task != null && q != null) { // Never null, hoist checks
src/java.base/share/classes/java/util/concurrent/ForkJoinPool.java line 1900:
> 1898: * giving up q is nonull and signalled slot already taken.
> 1899: */
> 1900: final void signalWork(WorkQueue q, int qbase) {
This is a nice improvement which also removes the risk of the underlying array for some reason (growth) getting swapped out midway.
src/java.base/share/classes/java/util/concurrent/ForkJoinPool.java line 1922:
> 1920: else
> 1921: nc = (v.stackPred & LMASK) | (c & TC_MASK) | ac;
> 1922: if (q != null && q.base - qbase > 0)
Cheaper and more robust check, I like it
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/28797#discussion_r2615796425
PR Review Comment: https://git.openjdk.org/jdk/pull/28797#discussion_r2615797362
PR Review Comment: https://git.openjdk.org/jdk/pull/28797#discussion_r2615797950
More information about the core-libs-dev
mailing list