8274349: ForkJoinPool.commonPool() does not work with 1 CPU

Co-authored-by: Doug Lea <dl@openjdk.org>
Reviewed-by: shade, martin
This commit is contained in:
David Holmes 2021-10-04 23:14:12 +00:00
parent 7e757f6a2c
commit 2e542e33b8
3 changed files with 84 additions and 4 deletions

View file

@ -2561,7 +2561,7 @@ public class ForkJoinPool extends AbstractExecutorService {
* overridden by system properties
*/
private ForkJoinPool(byte forCommonPoolOnly) {
int parallelism = Runtime.getRuntime().availableProcessors() - 1;
int parallelism = Math.max(1, Runtime.getRuntime().availableProcessors() - 1);
ForkJoinWorkerThreadFactory fac = null;
UncaughtExceptionHandler handler = null;
try { // ignore exceptions in accessing/parsing properties