563 |
|
* each probe via the "bound" parameter.) |
564 |
|
* |
565 |
|
* The compensation mechanism may be bounded. Bounds for the |
566 |
< |
* commonPool (see commonMaxSpares) better enable JVMs to cope |
566 |
> |
* commonPool (see COMMON_MAX_SPARES) better enable JVMs to cope |
567 |
|
* with programming errors and abuse before running out of |
568 |
|
* resources to do so. In other cases, users may supply factories |
569 |
|
* that limit thread construction. The effects of bounding in this |
1365 |
|
/** |
1366 |
|
* Limit on spare thread construction in tryCompensate. |
1367 |
|
*/ |
1368 |
< |
private static int commonMaxSpares; |
1368 |
> |
private static final int COMMON_MAX_SPARES; |
1369 |
|
|
1370 |
|
/** |
1371 |
|
* Sequence number for creating workerNamePrefix. |
1397 |
|
private static final long TIMEOUT_SLOP_MS = 20L; // 20ms |
1398 |
|
|
1399 |
|
/** |
1400 |
< |
* The initial value for commonMaxSpares during static |
1401 |
< |
* initialization unless overridden using System property |
1402 |
< |
* "java.util.concurrent.ForkJoinPool.common.maximumSpares". The |
1403 |
< |
* default value is far in excess of normal requirements, but also |
1404 |
< |
* far short of MAX_CAP and typical OS thread limits, so allows |
1405 |
< |
* JVMs to catch misuse/abuse before running out of resources |
1406 |
< |
* needed to do so. |
1400 |
> |
* The default value for COMMON_MAX_SPARES. Overridable using the |
1401 |
> |
* "java.util.concurrent.ForkJoinPool.common.maximumSpares" system |
1402 |
> |
* property. The default value is far in excess of normal |
1403 |
> |
* requirements, but also far short of MAX_CAP and typical OS |
1404 |
> |
* thread limits, so allows JVMs to catch misuse/abuse before |
1405 |
> |
* running out of resources needed to do so. |
1406 |
|
*/ |
1407 |
|
private static final int DEFAULT_COMMON_MAX_SPARES = 256; |
1408 |
|
|
2173 |
|
canBlock = U.compareAndSwapLong(this, CTL, c, nc); |
2174 |
|
} |
2175 |
|
else if (tc >= MAX_CAP || |
2176 |
< |
(this == common && tc >= pc + commonMaxSpares)) |
2176 |
> |
(this == common && tc >= pc + COMMON_MAX_SPARES)) |
2177 |
|
throw new RejectedExecutionException( |
2178 |
|
"Thread limit exceeded replacing blocked worker"); |
2179 |
|
else { // similar to tryAddWorker |
3471 |
|
// LockSupport.park: https://bugs.openjdk.java.net/browse/JDK-8074773 |
3472 |
|
Class<?> ensureLoaded = LockSupport.class; |
3473 |
|
|
3474 |
< |
commonMaxSpares = DEFAULT_COMMON_MAX_SPARES; |
3474 |
> |
int commonMaxSpares = DEFAULT_COMMON_MAX_SPARES; |
3475 |
> |
try { |
3476 |
> |
String p = System.getProperty |
3477 |
> |
("java.util.concurrent.ForkJoinPool.common.maximumSpares"); |
3478 |
> |
if (p != null) |
3479 |
> |
commonMaxSpares = Integer.parseInt(p); |
3480 |
> |
} catch (Exception ignore) {} |
3481 |
> |
COMMON_MAX_SPARES = commonMaxSpares; |
3482 |
> |
|
3483 |
|
defaultForkJoinWorkerThreadFactory = |
3484 |
|
new DefaultForkJoinWorkerThreadFactory(); |
3485 |
|
modifyThreadPermission = new RuntimePermission("modifyThread"); |
3506 |
|
("java.util.concurrent.ForkJoinPool.common.threadFactory"); |
3507 |
|
String hp = System.getProperty |
3508 |
|
("java.util.concurrent.ForkJoinPool.common.exceptionHandler"); |
3502 |
– |
String mp = System.getProperty |
3503 |
– |
("java.util.concurrent.ForkJoinPool.common.maximumSpares"); |
3509 |
|
if (pp != null) |
3510 |
|
parallelism = Integer.parseInt(pp); |
3511 |
|
if (fp != null) |
3514 |
|
if (hp != null) |
3515 |
|
handler = ((UncaughtExceptionHandler)ClassLoader. |
3516 |
|
getSystemClassLoader().loadClass(hp).newInstance()); |
3512 |
– |
if (mp != null) |
3513 |
– |
commonMaxSpares = Integer.parseInt(mp); |
3517 |
|
} catch (Exception ignore) { |
3518 |
|
} |
3519 |
|
if (factory == null) { |