RFR: 8274349: ForkJoinPool.commonPool() does not work with 1 CPU [v2]
Martin Buchholz
martin at openjdk.java.net
Fri Oct 1 17:00:35 UTC 2021
On Fri, 1 Oct 2021 05:10:17 GMT, David Holmes <dholmes at openjdk.org> wrote:
>> A regression introduced in Java 17 will give the default FJ pool a parallelism of zero in a uniprocessor environment. The fix restores this to a value of 1. See bug report for details.
>>
>> Testing:
>> - new regression test
>> - tiers 1-3
>>
>> Thanks,
>> David
>
> David Holmes has updated the pull request incrementally with one additional commit since the last revision:
>
> Updated TCK test component from @martin
Marked as reviewed by martin (Reviewer).
I always try to avoid Thread.sleep or polling in tests, so I would write the test like this:
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ForkJoinPool;
public class ForkJoinUniProcessor {
public static void main(String[] args) throws InterruptedException {
// If the default parallelism were zero then this task would not
// complete and the test will timeout.
CountDownLatch ran = new CountDownLatch(1);
ForkJoinPool.commonPool().submit(() -> ran.countDown());
ran.await();
}
}
-------------
PR: https://git.openjdk.java.net/jdk/pull/5784
More information about the core-libs-dev
mailing list