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

Comparing jsr166/src/main/java/util/concurrent/ForkJoinPool.java (file contents):
Revision 1.272 by dl, Sun Sep 13 11:44:08 2015 UTC vs.
Revision 1.273 by jsr166, Sat Sep 19 22:14:23 2015 UTC

# Line 563 | Line 563 | public class ForkJoinPool extends Abstra
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
# Line 1365 | Line 1365 | public class ForkJoinPool extends Abstra
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.
# Line 1397 | Line 1397 | public class ForkJoinPool extends Abstra
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  
# Line 2174 | Line 2173 | public class ForkJoinPool extends Abstra
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
# Line 3472 | Line 3471 | public class ForkJoinPool extends Abstra
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");
# Line 3499 | Line 3506 | public class ForkJoinPool extends Abstra
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)
# Line 3509 | Line 3514 | public class ForkJoinPool extends Abstra
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) {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines