ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/jdk8/java/util/concurrent/ForkJoinPool.java
(Generate patch)

Comparing jsr166/src/jdk8/java/util/concurrent/ForkJoinPool.java (file contents):
Revision 1.4 by jsr166, Tue Jun 28 14:52:19 2016 UTC vs.
Revision 1.5 by jsr166, Thu Sep 15 16:28:43 2016 UTC

# Line 2315 | Line 2315 | public class ForkJoinPool extends Abstra
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));
# Line 2328 | Line 2327 | public class ForkJoinPool extends Abstra
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;
# Line 2339 | Line 2338 | public class ForkJoinPool extends Abstra
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
# Line 2350 | Line 2358 | public class ForkJoinPool extends Abstra
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  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines