2315 |
|
throw new NullPointerException(); |
2316 |
|
long ms = Math.max(unit.toMillis(keepAliveTime), TIMEOUT_SLOP); |
2317 |
|
|
2318 |
– |
String prefix = "ForkJoinPool-" + nextPoolId() + "-worker-"; |
2318 |
|
int corep = Math.min(Math.max(corePoolSize, parallelism), MAX_CAP); |
2319 |
|
long c = ((((long)(-corep) << TC_SHIFT) & TC_MASK) | |
2320 |
|
(((long)(-parallelism) << RC_SHIFT) & RC_MASK)); |
2327 |
|
n = (n + 1) << 1; // power of two, including space for submission queues |
2328 |
|
|
2329 |
|
this.workQueues = new WorkQueue[n]; |
2330 |
< |
this.workerNamePrefix = prefix; |
2330 |
> |
this.workerNamePrefix = "ForkJoinPool-" + nextPoolId() + "-worker-"; |
2331 |
|
this.factory = factory; |
2332 |
|
this.ueh = handler; |
2333 |
|
this.saturate = saturate; |
2338 |
|
checkPermission(); |
2339 |
|
} |
2340 |
|
|
2341 |
+ |
private Object newInstanceFromSystemProperty(String property) |
2342 |
+ |
throws ReflectiveOperationException { |
2343 |
+ |
String className = System.getProperty(property); |
2344 |
+ |
return (className == null) |
2345 |
+ |
? null |
2346 |
+ |
: ClassLoader.getSystemClassLoader().loadClass(className) |
2347 |
+ |
.getConstructor().newInstance(); |
2348 |
+ |
} |
2349 |
+ |
|
2350 |
|
/** |
2351 |
|
* Constructor for common pool using parameters possibly |
2352 |
|
* overridden by system properties |
2358 |
|
try { // ignore exceptions in accessing/parsing properties |
2359 |
|
String pp = System.getProperty |
2360 |
|
("java.util.concurrent.ForkJoinPool.common.parallelism"); |
2353 |
– |
String fp = System.getProperty |
2354 |
– |
("java.util.concurrent.ForkJoinPool.common.threadFactory"); |
2355 |
– |
String hp = System.getProperty |
2356 |
– |
("java.util.concurrent.ForkJoinPool.common.exceptionHandler"); |
2361 |
|
if (pp != null) |
2362 |
|
parallelism = Integer.parseInt(pp); |
2363 |
< |
if (fp != null) |
2364 |
< |
fac = ((ForkJoinWorkerThreadFactory)ClassLoader. |
2365 |
< |
getSystemClassLoader().loadClass(fp).newInstance()); |
2366 |
< |
if (hp != null) |
2363 |
< |
handler = ((UncaughtExceptionHandler)ClassLoader. |
2364 |
< |
getSystemClassLoader().loadClass(hp).newInstance()); |
2363 |
> |
fac = (ForkJoinWorkerThreadFactory) newInstanceFromSystemProperty( |
2364 |
> |
"java.util.concurrent.ForkJoinPool.common.threadFactory"); |
2365 |
> |
handler = (UncaughtExceptionHandler) newInstanceFromSystemProperty( |
2366 |
> |
"java.util.concurrent.ForkJoinPool.common.exceptionHandler"); |
2367 |
|
} catch (Exception ignore) { |
2368 |
|
} |
2369 |
|
|