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

Comparing jsr166/src/jsr166y/ForkJoinPool.java (file contents):
Revision 1.148 by jsr166, Tue Nov 20 06:18:39 2012 UTC vs.
Revision 1.149 by dl, Wed Nov 21 19:54:39 2012 UTC

# Line 316 | Line 316 | public class ForkJoinPool extends Abstra
316       * execute. However, many other threads may notice the same task
317       * and each signal to wake up a thread that might take it. So in
318       * general, pools will be over-signalled.  When a submission is
319 <     * added or another worker adds a task to a queue that is
320 <     * apparently empty, they signal waiting workers (or trigger
321 <     * creation of new ones if fewer than the given parallelism
322 <     * level).  These primary signals are buttressed by signals
323 <     * whenever other threads scan for work or do not have a task to
324 <     * process (including the case of leaving a hint to unparked
325 <     * threads to help signal others upon wakeup).  On most platforms,
326 <     * signalling (unpark) overhead time is noticeably long, and the
327 <     * time between signalling a thread and it actually making
328 <     * progress can be very noticeably long, so it is worth offloading
329 <     * these delays from critical paths as much as possible.
319 >     * added or another worker adds a task to a queue that has fewer
320 >     * than two tasks, they signal waiting workers (or trigger
321 >     * creation of new ones if fewer than the given parallelism level
322 >     * -- signalWork), and may leave a hint to the unparked worker to
323 >     * help signal others upon wakeup).  These primary signals are
324 >     * buttressed by others (see method helpSignal) whenever other
325 >     * threads scan for work or do not have a task to process.  On
326 >     * most platforms, signalling (unpark) overhead time is noticeably
327 >     * long, and the time between signalling a thread and it actually
328 >     * making progress can be very noticeably long, so it is worth
329 >     * offloading these delays from critical paths as much as
330 >     * possible.
331       *
332       * Trimming workers. To release resources after periods of lack of
333       * use, a worker starting to wait when the pool is quiescent will
# Line 534 | Line 535 | public class ForkJoinPool extends Abstra
535      }
536  
537      /**
538 +     * Per-thread records for threads that submit to pools. Currently
539 +     * holds only pseudo-random seed / index that is used to choose
540 +     * submission queues in method externalPush. In the future, this may
541 +     * also incorporate a means to implement different task rejection
542 +     * and resubmission policies.
543 +     *
544 +     * Seeds for submitters and workers/workQueues work in basically
545 +     * the same way but are initialized and updated using slightly
546 +     * different mechanics. Both are initialized using the same
547 +     * approach as in class ThreadLocal, where successive values are
548 +     * unlikely to collide with previous values. Seeds are then
549 +     * randomly modified upon collisions using xorshifts, which
550 +     * requires a non-zero seed.
551 +     */
552 +    static final class Submitter {
553 +        int seed;
554 +        Submitter(int s) { seed = s; }
555 +    }
556 +
557 +    /**
558       * Class for artificial tasks that are used to replace the target
559       * of local joins if they are removed from an interior queue slot
560       * in WorkQueue.tryRemoveAndExec. We don't need the proxy to
# Line 599 | Line 620 | public class ForkJoinPool extends Abstra
620       * trades off slightly slower average field access for the sake of
621       * avoiding really bad worst-case access. (Until better JVM
622       * support is in place, this padding is dependent on transient
623 <     * properties of JVM field layout rules.)
623 >     * properties of JVM field layout rules.) We also take care in
624 >     * allocating, sizing and resizing the array. Non-shared queue
625 >     * arrays are initialized by workers before use. Others are
626 >     * allocated on first use.
627       */
628      static final class WorkQueue {
629          /**
# Line 622 | Line 646 | public class ForkJoinPool extends Abstra
646           */
647          static final int MAXIMUM_QUEUE_CAPACITY = 1 << 26; // 64M
648  
649 +        // Heuristic padding to ameliorate unfortunate memory placements
650 +        volatile long pad00, pad01, pad02, pad03, pad04, pad05, pad06;
651 +
652          int seed;                  // for random scanning; initialize nonzero
653          volatile int eventCount;   // encoded inactivation count; < 0 if inactive
654          int nextWait;              // encoded record of next event waiter
# Line 639 | Line 666 | public class ForkJoinPool extends Abstra
666          volatile ForkJoinTask<?> currentJoin;  // task being joined in awaitJoin
667          ForkJoinTask<?> currentSteal; // current non-local task being executed
668  
669 <        // Heuristic padding to ameliorate unfortunate memory placements
670 <        Object p00, p01, p02, p03, p04, p05, p06, p07;
644 <        Object p08, p09, p0a, p0b, p0c;
669 >        volatile Object pad10, pad11, pad12, pad13, pad14, pad15, pad16, pad17;
670 >        volatile Object pad18, pad19, pad1a, pad1b, pad1c, pad1d;
671  
672          WorkQueue(ForkJoinPool pool, ForkJoinWorkerThread owner, int mode,
673                    int seed) {
648            this.array = new ForkJoinTask<?>[WorkQueue.INITIAL_QUEUE_CAPACITY];
674              this.pool = pool;
675              this.owner = owner;
676              this.mode = mode;
677              this.seed = seed;
678 <            // Place indices in the center of array
678 >            // Place indices in the center of array (that is not yet allocated)
679              base = top = INITIAL_QUEUE_CAPACITY >>> 1;
680          }
681  
682          /**
683 <         * Pushes a task. Call only by owner in unshared queues.
684 <         * Cases needing resizing or rejection are relayed to fullPush
685 <         * (that also handles shared queues).
683 >         * Returns the approximate number of tasks in the queue.
684 >         */
685 >        final int queueSize() {
686 >            int n = base - top;       // non-owner callers must read base first
687 >            return (n >= 0) ? 0 : -n; // ignore transient negative
688 >        }
689 >
690 >       /**
691 >         * Provides a more accurate estimate of whether this queue has
692 >         * any tasks than does queueSize, by checking whether a
693 >         * near-empty queue has at least one unclaimed task.
694 >         */
695 >        final boolean isEmpty() {
696 >            ForkJoinTask<?>[] a; int m, s;
697 >            int n = base - (s = top);
698 >            return (n >= 0 ||
699 >                    (n == -1 &&
700 >                     ((a = array) == null ||
701 >                      (m = a.length - 1) < 0 ||
702 >                      U.getObject
703 >                      (a, (long)((m & (s - 1)) << ASHIFT) + ABASE) == null)));
704 >        }
705 >
706 >        /**
707 >         * Pushes a task. Call only by owner in unshared queues.  (The
708 >         * shared-queue version is embedded in method externalPush.)
709           *
710           * @param task the task. Caller must ensure non-null.
711           * @throw RejectedExecutionException if array cannot be resized
# Line 666 | Line 714 | public class ForkJoinPool extends Abstra
714              ForkJoinTask<?>[] a; ForkJoinPool p;
715              int s = top, m, n;
716              if ((a = array) != null) {    // ignore if queue removed
717 <                U.putOrderedObject
718 <                    (a, (((m = a.length - 1) & s) << ASHIFT) + ABASE, task);
719 <                if ((n = (top = s + 1) - base) <= 1) {
717 >                int j = (((m = a.length - 1) & s) << ASHIFT) + ABASE;
718 >                U.putOrderedObject(a, j, task);
719 >                if ((n = (top = s + 1) - base) <= 2) {
720                      if ((p = pool) != null)
721 <                        p.signalWork(this, 0);
721 >                        p.signalWork(this);
722                  }
723                  else if (n >= m)
724                      growArray();
725              }
726          }
727  
680        /**
681         * Pushes a task if lock is free and array is either big
682         * enough or can be resized to be big enough.
683         *
684         * @param task the task. Caller must ensure non-null.
685         * @return true if submitted
686         */
687        final boolean trySharedPush(ForkJoinTask<?> task) {
688            boolean submitted = false;
689            if (qlock == 0 && U.compareAndSwapInt(this, QLOCK, 0, 1)) {
690                ForkJoinTask<?>[] a = array;  ForkJoinPool p;
691                int s = top;
692                try {
693                    if ((a != null && a.length > s + 1 - base) ||
694                        (a = growArray()) != null) {   // must presize
695                        int j = (((a.length - 1) & s) << ASHIFT) + ABASE;
696                        U.putOrderedObject(a, j, task);
697                        top = s + 1;
698                        submitted = true;
699                    }
700                } finally {
701                    qlock = 0;                         // unlock
702                }
703                if (submitted && (p = pool) != null)
704                    p.signalWork(this, 0);
705            }
706            return submitted;
707        }
708
728         /**
729           * Initializes or doubles the capacity of array. Call either
730           * by owner or with lock held -- it is OK for base, but not
# Line 855 | Line 874 | public class ForkJoinPool extends Abstra
874              return seed = r ^= r << 5;
875          }
876  
858        /**
859         * Provides a more accurate estimate of size than (top - base)
860         * by ordering reads and checking whether a near-empty queue
861         * has at least one unclaimed task.
862         */
863        final int queueSize() {
864            ForkJoinTask<?>[] a; int k, s, n;
865            return ((n = base - (s = top)) < 0 &&
866                    (n != -1 ||
867                     ((a = array) != null && (k = a.length) > 0 &&
868                      U.getObject
869                      (a, (long)((((k - 1) & (s - 1)) << ASHIFT) + ABASE)) != null))) ?
870                -n : 0;
871        }
872
877          // Specialized execution methods
878  
879          /**
# Line 983 | Line 987 | public class ForkJoinPool extends Abstra
987              if (t != null) {
988                  (currentSteal = t).doExec();
989                  currentSteal = null;
990 <                ++nsteals;
987 <                if (top != base) {       // process remaining local tasks
990 >                if (base - top < 0) {       // process remaining local tasks
991                      if (mode == 0)
992                          popAndExecAll();
993                      else
994                          pollAndExecAll();
995                  }
996 +                ++nsteals;
997 +                hint = -1;
998              }
999          }
1000  
# Line 1066 | Line 1071 | public class ForkJoinPool extends Abstra
1071          defaultForkJoinWorkerThreadFactory;
1072  
1073      /**
1069     * Per-thread records for threads that submit to pools. Currently
1070     * holds only pseudo-random seed / index that is used to choose
1071     * submission queues in method externalPush. In the future, this may
1072     * also incorporate a means to implement different task rejection
1073     * and resubmission policies.
1074     *
1075     * Seeds for submitters and workers/workQueues work in basically
1076     * the same way but are initialized and updated using slightly
1077     * different mechanics. Both are initialized using the same
1078     * approach as in class ThreadLocal, where successive values are
1079     * unlikely to collide with previous values. Seeds are then
1080     * randomly modified upon collisions using xorshifts, which
1081     * requires a non-zero seed.
1082     */
1083    static final class Submitter {
1084        int seed;
1085        Submitter(int s) { seed = s; }
1086    }
1087
1088    /**
1074       * Per-thread submission bookkeeping. Shared across all pools
1075       * to reduce ThreadLocal pollution and because random motion
1076       * to avoid contention in one pool is likely to hold for others.
# Line 1095 | Line 1080 | public class ForkJoinPool extends Abstra
1080      static final ThreadLocal<Submitter> submitters;
1081  
1082      /**
1083 +     * Permission required for callers of methods that may start or
1084 +     * kill threads.
1085 +     */
1086 +    private static final RuntimePermission modifyThreadPermission;
1087 +
1088 +    /**
1089       * Common (static) pool. Non-null for public use unless a static
1090       * construction exception, but internal usages null-check on use
1091       * to paranoically avoid potential initialization circularities
# Line 1103 | Line 1094 | public class ForkJoinPool extends Abstra
1094      static final ForkJoinPool commonPool;
1095  
1096      /**
1106     * Permission required for callers of methods that may start or
1107     * kill threads.
1108     */
1109    private static final RuntimePermission modifyThreadPermission;
1110
1111    /**
1097       * Common pool parallelism. Must equal commonPool.parallelism.
1098       */
1099      static final int commonPoolParallelism;
# Line 1255 | Line 1240 | public class ForkJoinPool extends Abstra
1240       * declaration order and may differ across JVMs, but the following
1241       * empirically works OK on current JVMs.
1242       */
1243 +
1244 +    // Heuristic padding to ameliorate unfortunate memory placements
1245 +    volatile long pad00, pad01, pad02, pad03, pad04, pad05, pad06;
1246 +
1247      volatile long stealCount;                  // collects worker counts
1248      volatile long ctl;                         // main pool control
1249      volatile int plock;                        // shutdown status and seqLock
# Line 1265 | Line 1254 | public class ForkJoinPool extends Abstra
1254      final Thread.UncaughtExceptionHandler ueh; // per-worker UEH
1255      final String workerNamePrefix;             // to create worker name string
1256  
1257 +    volatile Object pad10, pad11, pad12, pad13, pad14, pad15, pad16, pad17;
1258 +    volatile Object pad18, pad19, pad1a, pad1b;
1259 +
1260      /*
1261       * Acquires the plock lock to protect worker array and related
1262       * updates. This method is called only if an initial CAS on plock
# Line 1325 | Line 1317 | public class ForkJoinPool extends Abstra
1317      }
1318  
1319      /**
1328     * Tries to create and start a worker; adjusts counts etc on failure
1329     */
1330    private void addWorker() {
1331        ForkJoinWorkerThread wt = null;
1332        try {
1333            (wt = factory.newThread(this)).start();
1334        } catch (Throwable ex) {
1335            deregisterWorker(wt, ex); // adjust on failure
1336        }
1337    }
1338
1339    /**
1320       * Performs secondary initialization, called when plock is zero.
1321       * Creates workQueue array and sets plock to a valid value.  The
1322       * lock body must be exception-free (so no try/finally) so we
# Line 1345 | Line 1325 | public class ForkJoinPool extends Abstra
1325       * fullExternalPush.)  Because the plock seq value can eventually
1326       * wrap around zero, this method harmlessly fails to reinitialize
1327       * if workQueues exists, while still advancing plock.
1328 +     *
1329 +     * Additonally tries to create the first worker.
1330       */
1331 <    private void initWorkQueuesArray() {
1332 <        WorkQueue[] ws; int ps;
1331 >    private void initWorkers() {
1332 >        WorkQueue[] ws, nws; int ps;
1333          int p = config & SMASK;        // find power of two table size
1334          int n = (p > 1) ? p - 1 : 1;   // ensure at least 2 slots
1335          n |= n >>> 1; n |= n >>> 2; n |= n >>> 4; n |= n >>> 8; n |= n >>> 16;
1336 <        WorkQueue[] nws = new WorkQueue[(n + 1) << 1];
1336 >        n = (n + 1) << 1;
1337 >        if ((ws = workQueues) == null || ws.length == 0)
1338 >            nws = new WorkQueue[n];
1339 >        else
1340 >            nws = null;
1341          if (((ps = plock) & PL_LOCK) != 0 ||
1342              !U.compareAndSwapInt(this, PLOCK, ps, ps += PL_LOCK))
1343              ps = acquirePlock();
1344 <        if ((ws = workQueues) == null || ws.length == 0)
1344 >        if (((ws = workQueues) == null || ws.length == 0) && nws != null)
1345              workQueues = nws;
1346          int nps = (ps & SHUTDOWN) | ((ps + PL_LOCK) & ~SHUTDOWN);
1347          if (!U.compareAndSwapInt(this, PLOCK, ps, nps))
1348              releasePlock(nps);
1349 +        tryAddWorker();
1350 +    }
1351 +
1352 +    /**
1353 +     * Tries to create and start one worker. Adjusts counts etc on
1354 +     * failure.
1355 +     */
1356 +    private void tryAddWorker() {
1357          long c; int u;
1358 <        if ((u = (int)((c = ctl) >>> 32)) < 0 && (int)c == 0) {
1358 >        while ((u = (int)((c = ctl) >>> 32)) < 0 &&
1359 >               (u & SHORT_SIGN) != 0 && (int)c == 0) {
1360              long nc = (long)(((u + UTC_UNIT) & UTC_MASK) |
1361                               ((u + UAC_UNIT) & UAC_MASK)) << 32;
1362 <            if (U.compareAndSwapLong(this, CTL, c, nc))
1363 <                addWorker();
1362 >            if (U.compareAndSwapLong(this, CTL, c, nc)) {
1363 >                ForkJoinWorkerThreadFactory fac;
1364 >                Throwable ex = null;
1365 >                ForkJoinWorkerThread wt = null;
1366 >                try {
1367 >                    if ((fac = factory) != null &&
1368 >                        (wt = fac.newThread(this)) != null) {
1369 >                        wt.start();
1370 >                        break;
1371 >                    }
1372 >                } catch (Throwable e) {
1373 >                    ex = e;
1374 >                }
1375 >                deregisterWorker(wt, ex);
1376 >                break;
1377 >            }
1378          }
1370
1379      }
1380  
1381      //  Registering and deregistering workers
# Line 1380 | Line 1388 | public class ForkJoinPool extends Abstra
1388       * expanding as needed.
1389       *
1390       * @param wt the worker thread
1391 +     * @return the worker's queue
1392       */
1393 <    final void registerWorker(ForkJoinWorkerThread wt) {
1394 <        if (wt != null && wt.workQueue == null) {
1395 <            int s, ps;    // generate a rarely colliding candidate index seed
1396 <            do {} while (!U.compareAndSwapInt(this, INDEXSEED, s = indexSeed,
1397 <                                              s += SEED_INCREMENT) ||
1398 <                         s == 0); // skip 0
1399 <            WorkQueue w = new WorkQueue(this, wt, config >>> 16, s);
1400 <            if (((ps = plock) & PL_LOCK) != 0 ||
1401 <                !U.compareAndSwapInt(this, PLOCK, ps, ps += PL_LOCK))
1402 <                ps = acquirePlock();
1403 <            int nps = (ps & SHUTDOWN) | ((ps + PL_LOCK) & ~SHUTDOWN);
1404 <            try {
1405 <                WorkQueue[] ws;
1406 <                if ((ws = workQueues) != null && wt.workQueue == null) {
1407 <                    int n = ws.length, m = n - 1;
1408 <                    int r = (s << 1) | 1;           // use odd-numbered indices
1409 <                    if (ws[r &= m] != null) {       // collision
1410 <                        int probes = 0;             // step by approx half size
1411 <                        int step = (n <= 4) ? 2 : ((n >>> 1) & EVENMASK) + 2;
1412 <                        while (ws[r = (r + step) & m] != null) {
1413 <                            if (++probes >= n) {
1414 <                                workQueues = ws = Arrays.copyOf(ws, n <<= 1);
1415 <                                m = n - 1;
1416 <                                probes = 0;
1417 <                            }
1393 >    final WorkQueue registerWorker(ForkJoinWorkerThread wt) {
1394 >        Thread.UncaughtExceptionHandler handler; WorkQueue[] ws; int s, ps;
1395 >        wt.setDaemon(true);
1396 >        if ((handler = ueh) != null)
1397 >            wt.setUncaughtExceptionHandler(handler);
1398 >        do {} while (!U.compareAndSwapInt(this, INDEXSEED, s = indexSeed,
1399 >                                          s += SEED_INCREMENT) ||
1400 >                     s == 0); // skip 0
1401 >        WorkQueue w = new WorkQueue(this, wt, config >>> 16, s);
1402 >        if (((ps = plock) & PL_LOCK) != 0 ||
1403 >            !U.compareAndSwapInt(this, PLOCK, ps, ps += PL_LOCK))
1404 >            ps = acquirePlock();
1405 >        int nps = (ps & SHUTDOWN) | ((ps + PL_LOCK) & ~SHUTDOWN);
1406 >        try {
1407 >            if ((ws = workQueues) != null) {    // skip if shutting down
1408 >                int n = ws.length, m = n - 1;
1409 >                int r = (s << 1) | 1;           // use odd-numbered indices
1410 >                if (ws[r &= m] != null) {       // collision
1411 >                    int probes = 0;             // step by approx half size
1412 >                    int step = (n <= 4) ? 2 : ((n >>> 1) & EVENMASK) + 2;
1413 >                    while (ws[r = (r + step) & m] != null) {
1414 >                        if (++probes >= n) {
1415 >                            workQueues = ws = Arrays.copyOf(ws, n <<= 1);
1416 >                            m = n - 1;
1417 >                            probes = 0;
1418                          }
1419                      }
1411                    w.eventCount = w.poolIndex = r; // volatile write orders
1412                    wt.workQueue = ws[r] = w;
1420                  }
1421 <            } finally {
1422 <                if (!U.compareAndSwapInt(this, PLOCK, ps, nps))
1416 <                    releasePlock(nps);
1421 >                w.eventCount = w.poolIndex = r; // volatile write orders
1422 >                ws[r] = w;
1423              }
1424 +        } finally {
1425 +            if (!U.compareAndSwapInt(this, PLOCK, ps, nps))
1426 +                releasePlock(nps);
1427          }
1428 +        wt.setName(workerNamePrefix.concat(Integer.toString(w.poolIndex)));
1429 +        return w;
1430      }
1431  
1432      /**
# Line 1459 | Line 1470 | public class ForkJoinPool extends Abstra
1470          if (!tryTerminate(false, false) && w != null) {
1471              w.cancelAll();                  // cancel remaining tasks
1472              if (w.array != null)            // suppress signal if never ran
1473 <                helpSignal(null, 0);        // wake up or create replacement
1473 >                tryAddWorker();             // create replacement
1474              if (ex == null)                 // help clean refs on way out
1475                  ForkJoinTask.helpExpungeStaleExceptions();
1476          }
# Line 1486 | Line 1497 | public class ForkJoinPool extends Abstra
1497              U.compareAndSwapInt(q, QLOCK, 0, 1)) { // lock
1498              int b = q.base, s = q.top, n, an;
1499              if ((a = q.array) != null && (an = a.length) > (n = s + 1 - b)) {
1500 <                U.putObject(a, (long)(((an - 1) & s) << ASHIFT) + ABASE, task);
1500 >                int j = (((an - 1) & s) << ASHIFT) + ABASE;
1501 >                U.putOrderedObject(a, j, task);
1502                  q.top = s + 1;                     // push on to deque
1503                  q.qlock = 0;
1504                  if (n <= 2)
1505 <                    signalWork(q, 0);
1505 >                    signalWork(q);
1506                  return;
1507              }
1508              q.qlock = 0;
# Line 1502 | Line 1514 | public class ForkJoinPool extends Abstra
1514       * Full version of externalPush. This method is called, among
1515       * other times, upon the first submission of the first task to the
1516       * pool, so must perform secondary initialization (via
1517 <     * initWorkQueuesArray). It also detects first submission by an
1518 <     * external thread by looking up its ThreadLocal, and creates a
1519 <     * new shared queue if the one at index if empty or contended. The
1520 <     * lock body must be exception-free (so no try/finally) so we
1517 >     * initWorkers). It also detects first submission by an external
1518 >     * thread by looking up its ThreadLocal, and creates a new shared
1519 >     * queue if the one at index if empty or contended. The plock lock
1520 >     * body must be exception-free (so no try/finally) so we
1521       * optimistically allocate new queues outside the lock and throw
1522       * them away if (very rarely) not needed.
1523       */
1524      private void fullExternalPush(ForkJoinTask<?> task) {
1525 <        int r = 0;
1525 >        int r = 0; // random index seed
1526          for (Submitter z = submitters.get();;) {
1527              WorkQueue[] ws; WorkQueue q; int ps, m, k;
1528              if (z == null) {
# Line 1528 | Line 1540 | public class ForkJoinPool extends Abstra
1540                  throw new RejectedExecutionException();
1541              else if (ps == 0 || (ws = workQueues) == null ||
1542                       (m = ws.length - 1) < 0)
1543 <                initWorkQueuesArray();
1543 >                initWorkers();
1544              else if ((q = ws[k = r & m & SQMASK]) != null) {
1545 <                if (q.trySharedPush(task))
1546 <                    return;
1547 <                else
1548 <                    r = 0; // move on contention
1545 >                if (q.qlock == 0 && U.compareAndSwapInt(q, QLOCK, 0, 1)) {
1546 >                    ForkJoinTask<?>[] a = q.array;
1547 >                    int s = q.top;
1548 >                    boolean submitted = false;
1549 >                    try {                      // locked version of push
1550 >                        if ((a != null && a.length > s + 1 - q.base) ||
1551 >                            (a = q.growArray()) != null) {   // must presize
1552 >                            int j = (((a.length - 1) & s) << ASHIFT) + ABASE;
1553 >                            U.putOrderedObject(a, j, task);
1554 >                            q.top = s + 1;
1555 >                            submitted = true;
1556 >                        }
1557 >                    } finally {
1558 >                        q.qlock = 0;  // unlock
1559 >                    }
1560 >                    if (submitted) {
1561 >                        signalWork(q);
1562 >                        return;
1563 >                    }
1564 >                }
1565 >                r = 0; // move on failure
1566              }
1567              else if (((ps = plock) & PL_LOCK) == 0) { // create new queue
1568                  q = new WorkQueue(this, null, SHARED_QUEUE, r);
# Line 1562 | Line 1591 | public class ForkJoinPool extends Abstra
1591      }
1592  
1593      /**
1594 <     * Tries to create (at most one) or activate (possibly several)
1595 <     * workers if too few are active. On contention failure, continues
1596 <     * until at least one worker is signalled or the given queue is
1568 <     * empty or all workers are active.
1569 <     *
1570 <     * @param q if non-null, the queue holding tasks to be signalled
1571 <     * @param signals the target number of signals (at least one --
1572 <     * if argument is zero also sets signallee hint if parked).
1594 >     * Tries to create or activate a worker if too few are active.
1595 >     *
1596 >     * @param q the (non-null) queue holding tasks to be signalled
1597       */
1598 <    final void signalWork(WorkQueue q, int signals) {
1599 <        long c; int e, u, i, s; WorkQueue[] ws; WorkQueue w; Thread p;
1598 >    final void signalWork(WorkQueue q) {
1599 >        int hint = q.poolIndex;
1600 >        long c; int e, u, i, n; WorkQueue[] ws; WorkQueue w; Thread p;
1601          while ((u = (int)((c = ctl) >>> 32)) < 0) {
1602              if ((e = (int)c) > 0) {
1603                  if ((ws = workQueues) != null && ws.length > (i = e & SMASK) &&
# Line 1580 | Line 1605 | public class ForkJoinPool extends Abstra
1605                      long nc = (((long)(w.nextWait & E_MASK)) |
1606                                 ((long)(u + UAC_UNIT) << 32));
1607                      if (U.compareAndSwapLong(this, CTL, c, nc)) {
1608 +                        w.hint = hint;
1609                          w.eventCount = (e + E_SEQ) & E_MASK;
1610 <                        if ((p = w.parker) != null) {
1585 <                            if (q != null && signals == 0)
1586 <                                w.hint = q.poolIndex;
1610 >                        if ((p = w.parker) != null)
1611                              U.unpark(p);
1612 <                        }
1589 <                        if (--signals <= 0)
1590 <                            break;
1612 >                        break;
1613                      }
1614 <                    if (q != null && (s = q.queueSize()) <= signals &&
1593 <                         (signals = s) <= 0)
1614 >                    if (q.top - q.base <= 0)
1615                          break;
1616                  }
1617                  else
1618                      break;
1619              }
1620 <            else if (e == 0 && (u & SHORT_SIGN) != 0) {
1621 <                long nc = (long)(((u + UTC_UNIT) & UTC_MASK) |
1622 <                                 ((u + UAC_UNIT) & UAC_MASK)) << 32;
1602 <                if (U.compareAndSwapLong(this, CTL, c, nc)) {
1603 <                    addWorker();
1604 <                    break;
1605 <                }
1606 <            }
1607 <            else
1620 >            else {
1621 >                if ((short)u < 0)
1622 >                    tryAddWorker();
1623                  break;
1624 +            }
1625          }
1626      }
1627  
# Line 1615 | Line 1631 | public class ForkJoinPool extends Abstra
1631       * Top-level runloop for workers, called by ForkJoinWorkerThread.run.
1632       */
1633      final void runWorker(WorkQueue w) {
1634 <        if (w != null) // skip on initialization failure
1635 <            do { w.runTask(scan(w)); } while (w.qlock >= 0);
1634 >        w.growArray(); // allocate queue
1635 >        do { w.runTask(scan(w)); } while (w.qlock >= 0);
1636      }
1637  
1638      /**
# Line 1655 | Line 1671 | public class ForkJoinPool extends Abstra
1671       * @return a task or null if none found
1672       */
1673      private final ForkJoinTask<?> scan(WorkQueue w) {
1674 <        WorkQueue[] ws; int m, hint;
1674 >        WorkQueue[] ws; int m;
1675          int ps = plock;                          // read plock before ws
1676          if (w != null && (ws = workQueues) != null && (m = ws.length - 1) >= 0) {
1677              int ec = w.eventCount;               // ec is negative if inactive
1678              int r = w.seed; r ^= r << 13; r ^= r >>> 17; w.seed = r ^= r << 5;
1679 <            for (int j = ((m + m + 1) | MIN_SCAN) & MAX_SCAN; ; --j) {
1679 >            int j = ((m + m + 1) | MIN_SCAN) & MAX_SCAN;
1680 >            do {
1681                  WorkQueue q; ForkJoinTask<?>[] a; int b;
1682                  if ((q = ws[(r + j) & m]) != null && (b = q.base) - q.top < 0 &&
1683                      (a = q.array) != null) {     // probably nonempty
# Line 1670 | Line 1687 | public class ForkJoinPool extends Abstra
1687                      if (q.base == b && ec >= 0 && t != null &&
1688                          U.compareAndSwapObject(a, i, t, null)) {
1689                          if ((q.base = b + 1) - q.top < 0)
1690 <                            signalWork(q, 0);
1690 >                            signalWork(q);
1691                          return t;                // taken
1692                      }
1693 <                    else if (ec < 0 || j < m) {  // cannot take or cannot rescan
1694 <                        w.hint = q.poolIndex;    // use hint below
1695 <                        break;                   // let caller retry after signal
1696 <                    }
1697 <                }
1698 <                else if (j < 0) { // end of scan; in loop to simplify code
1699 <                    long c, sc; int e, ns;
1700 <                    if ((ns = w.nsteals) != 0) {
1701 <                        if (U.compareAndSwapLong(this, STEALCOUNT,
1702 <                                                 sc = stealCount, sc + ns))
1703 <                            w.nsteals = 0;       // collect steals
1704 <                    }
1705 <                    else if (plock != ps)        // ws may have changed
1706 <                        break;
1707 <                    else if ((e = (int)(c = ctl)) < 0)
1708 <                        w.qlock = -1;            // pool is terminating
1709 <                    else if (ec >= 0) {          // try to enqueue/inactivate
1710 <                        long nc = ((long)ec |
1711 <                                   ((c - AC_UNIT) & (AC_MASK|TC_MASK)));
1712 <                        w.nextWait = e;          // link and mark inactive
1713 <                        w.hint = -1;             // use hint if set while parked
1714 <                        w.eventCount = ec | INT_SIGN;
1715 <                        if (ctl != c ||
1716 <                            !U.compareAndSwapLong(this, CTL, c, nc))
1717 <                            w.eventCount = ec;  // unmark on CAS failure
1718 <                        else if ((int)(c >> AC_SHIFT) == 1 - (config & SMASK))
1719 <                            idleAwaitWork(w, nc, c);
1720 <                    }
1721 <                    else if (w.eventCount < 0) { // block
1722 <                        Thread wt = Thread.currentThread();
1723 <                        Thread.interrupted();    // clear status
1724 <                        U.putObject(wt, PARKBLOCKER, this);
1725 <                        w.parker = wt;           // emulate LockSupport.park
1726 <                        if (w.eventCount < 0)    // recheck
1727 <                            U.park(false, 0L);
1728 <                        w.parker = null;
1729 <                        U.putObject(wt, PARKBLOCKER, null);
1730 <                    }
1731 <                    break;
1732 <                }
1733 <            }
1717 <            if ((hint = w.hint) >= 0) {          // help signal
1718 <                WorkQueue[] vs; WorkQueue v; int k;
1719 <                w.hint = -1;                     // suppress resignal
1720 <                if ((vs = workQueues) != null && hint < vs.length &&
1721 <                    (v = vs[hint]) != null && (k = v.base - v.top) < -1)
1722 <                    signalWork(v, 1 - k);
1693 >                    else if ((ec < 0 || j < m) && (int)(ctl >> AC_SHIFT) <= 0) {
1694 >                        w.hint = (r + j) & m;    // help signal below
1695 >                        break;                   // cannot take
1696 >                    }
1697 >                }
1698 >            } while (--j >= 0);
1699 >
1700 >            long c, sc; int e, ns, h;
1701 >            if ((h = w.hint) < 0) {
1702 >                if ((ns = w.nsteals) != 0) {
1703 >                    if (U.compareAndSwapLong(this, STEALCOUNT,
1704 >                                             sc = stealCount, sc + ns))
1705 >                        w.nsteals = 0;           // collect steals
1706 >                }
1707 >                else if (plock != ps)            // consistency check
1708 >                    ;                            // skip
1709 >                else if ((e = (int)(c = ctl)) < 0)
1710 >                    w.qlock = -1;                // pool is terminating
1711 >                else if (ec >= 0) {              // try to enqueue/inactivate
1712 >                    long nc = ((long)ec | ((c - AC_UNIT) & (AC_MASK|TC_MASK)));
1713 >                    w.nextWait = e;              // link and mark inactive
1714 >                    w.eventCount = ec | INT_SIGN;
1715 >                    if (ctl != c || !U.compareAndSwapLong(this, CTL, c, nc))
1716 >                        w.eventCount = ec;       // unmark on CAS failure
1717 >                    else if ((int)(c >> AC_SHIFT) == 1 - (config & SMASK))
1718 >                        idleAwaitWork(w, nc, c);
1719 >                }
1720 >                else if (w.eventCount < 0) {     // block
1721 >                    Thread wt = Thread.currentThread();
1722 >                    Thread.interrupted();        // clear status
1723 >                    U.putObject(wt, PARKBLOCKER, this);
1724 >                    w.parker = wt;               // emulate LockSupport.park
1725 >                    if (w.eventCount < 0)        // recheck
1726 >                        U.park(false, 0L);
1727 >                    w.parker = null;
1728 >                    U.putObject(wt, PARKBLOCKER, null);
1729 >                }
1730 >            }
1731 >            if (h >= 0 || (h = w.hint) >= 0) {   // signal others before retry
1732 >                w.hint = -1;                     // reset
1733 >                helpSignal(null, h, true);
1734              }
1735          }
1736          return null;
# Line 1758 | Line 1769 | public class ForkJoinPool extends Abstra
1769                      U.compareAndSwapLong(this, CTL, currentCtl, prevCtl)) {
1770                      w.eventCount = (w.eventCount + E_SEQ) | E_MASK;
1771                      w.qlock = -1;   // shrink
1761                    w.hint = -1;    // suppress helping
1772                      break;
1773                  }
1774              }
# Line 1767 | Line 1777 | public class ForkJoinPool extends Abstra
1777  
1778      /**
1779       * Scans through queues looking for work (optionally, while
1780 <     * joining a task); if any are present, signals. May return early
1781 <     * if more signalling is detectably unneeded.
1780 >     * joining a task); if any present, signals. May return early if
1781 >     * more signalling is detectably unneeded.
1782       *
1783       * @param task if non-null, return early if done
1784       * @param origin an index to start scan
1785 +     * @param once if only the origin should be checked
1786       */
1787 <    final int helpSignal(ForkJoinTask<?> task, int origin) {
1788 <        WorkQueue[] ws; WorkQueue q; int m, n, s, u;
1789 <        if ((ws = workQueues) != null && (m = ws.length - 1) >= 0) {
1790 <            for (int i = 0; i <= m; ++i) {
1791 <                if (task != null && (s = task.status) < 0)
1792 <                    return s;
1793 <                if ((q = ws[(i + origin) & m]) != null &&
1794 <                    (n = q.queueSize()) > 0) {
1795 <                    signalWork(q, n);
1796 <                    if ((u = (int)(ctl >>> 32)) >= 0 || (u >> UAC_SHIFT) >= 0)
1787 >    private void helpSignal(ForkJoinTask<?> task, int origin, boolean once) {
1788 >        WorkQueue[] ws; WorkQueue w; Thread p; long c; int m, u, e, i, s;
1789 >        if ((u = (int)(ctl >>> 32)) < 0 && (u >> UAC_SHIFT) < 0 &&
1790 >            (ws = workQueues) != null && (m = ws.length - 1) >= 0) {
1791 >            outer: for (int k = origin, j = once? 0 : m; j >= 0; --j) {
1792 >                WorkQueue q = ws[k++ & m];
1793 >                for (int n = m;;) { // limit to at most m signals
1794 >                    if (task != null && task.status < 0)
1795 >                        break outer;
1796 >                    if (q == null ||
1797 >                        ((s = (task == null ? -1 : 0) - q.base + q.top) <= n &&
1798 >                         (n = s) <= 0))
1799                          break;
1800 +                    if ((u = (int)((c = ctl) >>> 32)) >= 0 ||
1801 +                        (e = (int)c) <= 0 || m < (i = e & SMASK) ||
1802 +                        (w = ws[i]) == null)
1803 +                        break outer;
1804 +                    long nc = (((long)(w.nextWait & E_MASK)) |
1805 +                               ((long)(u + UAC_UNIT) << 32));
1806 +                    if (w.eventCount == (e | INT_SIGN) &&
1807 +                        U.compareAndSwapLong(this, CTL, c, nc)) {
1808 +                        w.eventCount = (e + E_SEQ) & E_MASK;
1809 +                        if ((p = w.parker) != null)
1810 +                            U.unpark(p);
1811 +                        if (--n <= 0)
1812 +                            break;
1813 +                    }
1814                  }
1815              }
1816          }
1790        return 0;
1817      }
1818  
1819      /**
# Line 1936 | Line 1962 | public class ForkJoinPool extends Abstra
1962              else if (tc + pc < MAX_CAP) {
1963                  long nc = ((c + TC_UNIT) & TC_MASK) | (c & ~TC_MASK);
1964                  if (U.compareAndSwapLong(this, CTL, c, nc)) {
1965 <                    addWorker();
1966 <                    return true;
1965 >                    ForkJoinWorkerThreadFactory fac;
1966 >                    Throwable ex = null;
1967 >                    ForkJoinWorkerThread wt = null;
1968 >                    try {
1969 >                        if ((fac = factory) != null &&
1970 >                            (wt = fac.newThread(this)) != null) {
1971 >                            wt.start();
1972 >                            return true;
1973 >                        }
1974 >                    } catch (Throwable rex) {
1975 >                        ex = rex;
1976 >                    }
1977 >                    deregisterWorker(wt, ex); // clean up and return false
1978                  }
1979              }
1980          }
# Line 1956 | Line 1993 | public class ForkJoinPool extends Abstra
1993          if (joiner != null && task != null && (s = task.status) >= 0) {
1994              ForkJoinTask<?> prevJoin = joiner.currentJoin;
1995              joiner.currentJoin = task;
1996 <            do {} while ((s = task.status) >= 0 &&
1960 <                         joiner.queueSize() > 0 &&
1996 >            do {} while ((s = task.status) >= 0 && !joiner.isEmpty() &&
1997                           joiner.tryRemoveAndExec(task)); // process local tasks
1998 <            if (s >= 0 && (s = task.status) >= 0 &&
1999 <                (s = helpSignal(task, joiner.poolIndex)) >= 0 &&
2000 <                (task instanceof CountedCompleter))
2001 <                s = helpComplete(task, LIFO_QUEUE);
2002 <            int k = 0; // to perform pre-block yield for politeness
1998 >            if (s >= 0 && (s = task.status) >= 0) {
1999 >                helpSignal(task, joiner.poolIndex, false);
2000 >                if ((s = task.status) >= 0 &&
2001 >                    (task instanceof CountedCompleter))
2002 >                    s = helpComplete(task, LIFO_QUEUE);
2003 >            }
2004              while (s >= 0 && (s = task.status) >= 0) {
2005 <                if ((joiner.queueSize() > 0 ||           // try helping
2005 >                if ((!joiner.isEmpty() ||           // try helping
2006                       (s = tryHelpStealer(joiner, task)) == 0) &&
2007                      (s = task.status) >= 0) {
2008 <                    if (k < 3) {
2009 <                        if (++k < 3)
1973 <                            s = helpSignal(task, joiner.poolIndex);
1974 <                        else
1975 <                            Thread.yield();
1976 <                    }
1977 <                    else if (!tryCompensate())
1978 <                        k = 0;
1979 <                    else {
2008 >                    helpSignal(task, joiner.poolIndex, false);
2009 >                    if ((s = task.status) >= 0 && tryCompensate()) {
2010                          if (task.trySetSignal() && (s = task.status) >= 0) {
2011                              synchronized (task) {
2012                                  if (task.status >= 0) {
# Line 2013 | Line 2043 | public class ForkJoinPool extends Abstra
2043          if (joiner != null && task != null && (s = task.status) >= 0) {
2044              ForkJoinTask<?> prevJoin = joiner.currentJoin;
2045              joiner.currentJoin = task;
2046 <            do {} while ((s = task.status) >= 0 &&
2017 <                         joiner.queueSize() > 0 &&
2046 >            do {} while ((s = task.status) >= 0 && !joiner.isEmpty() &&
2047                           joiner.tryRemoveAndExec(task));
2048 <            if (s >= 0 && (s = task.status) >= 0 &&
2049 <                (s = helpSignal(task, joiner.poolIndex)) >= 0 &&
2050 <                (task instanceof CountedCompleter))
2051 <                s = helpComplete(task, LIFO_QUEUE);
2052 <            if (s >= 0 && joiner.queueSize() == 0) {
2048 >            if (s >= 0 && (s = task.status) >= 0) {
2049 >                helpSignal(task, joiner.poolIndex, false);
2050 >                if ((s = task.status) >= 0 &&
2051 >                    (task instanceof CountedCompleter))
2052 >                    s = helpComplete(task, LIFO_QUEUE);
2053 >            }
2054 >            if (s >= 0 && joiner.isEmpty()) {
2055                  do {} while (task.status >= 0 &&
2056                               tryHelpStealer(joiner, task) > 0);
2057              }
# Line 2042 | Line 2073 | public class ForkJoinPool extends Abstra
2073                  return null;
2074              for (int j = (m + 1) << 2; ;) {
2075                  WorkQueue q = ws[(((r + j) << 1) | 1) & m];
2076 <                if (q != null && (n = q.queueSize()) > 0) {
2077 <                    if (n > 1)
2078 <                        signalWork(q, 0);
2076 >                if (q != null && (n = q.base - q.top) < 0) {
2077 >                    if (n < -1)
2078 >                        signalWork(q);
2079                      return q;
2080                  }
2081                  else if (--j < 0) {
# Line 2286 | Line 2317 | public class ForkJoinPool extends Abstra
2317       */
2318      static boolean tryExternalUnpush(ForkJoinTask<?> t) {
2319          ForkJoinPool p; WorkQueue[] ws; WorkQueue q; Submitter z;
2320 <        ForkJoinTask<?>[] a;  int m, s; long j;
2321 <        if ((z = submitters.get()) != null &&
2320 >        ForkJoinTask<?>[] a;  int m, s;
2321 >        if (t != null &&
2322 >            (z = submitters.get()) != null &&
2323              (p = commonPool) != null &&
2324              (ws = p.workQueues) != null &&
2325              (m = ws.length - 1) >= 0 &&
2326              (q = ws[m & z.seed & SQMASK]) != null &&
2327              (s = q.top) != q.base &&
2328 <            (a = q.array) != null &&
2329 <            U.getObjectVolatile
2330 <            (a, j = (((a.length - 1) & (s - 1)) << ASHIFT) + ABASE) == t &&
2331 <            U.compareAndSwapInt(q, QLOCK, 0, 1)) {
2332 <            if (q.array == a && q.top == s && // recheck
2333 <                U.compareAndSwapObject(a, j, t, null)) {
2334 <                q.top = s - 1;
2328 >            (a = q.array) != null) {
2329 >            long j = (((a.length - 1) & (s - 1)) << ASHIFT) + ABASE;
2330 >            if (U.getObject(a, j) == t &&
2331 >                U.compareAndSwapInt(q, QLOCK, 0, 1)) {
2332 >                if (q.array == a && q.top == s && // recheck
2333 >                    U.compareAndSwapObject(a, j, t, null)) {
2334 >                    q.top = s - 1;
2335 >                    q.qlock = 0;
2336 >                    return true;
2337 >                }
2338                  q.qlock = 0;
2304                return true;
2339              }
2306            q.qlock = 0;
2340          }
2341          return false;
2342      }
# Line 2345 | Line 2378 | public class ForkJoinPool extends Abstra
2378                      (u = (int)(ctl >>> 32)) >= 0 || (u >> UAC_SHIFT) >= 0)
2379                      break;
2380                  if (task == null) {
2381 <                    if (helpSignal(root, q.poolIndex) >= 0)
2381 >                    helpSignal(root, q.poolIndex, false);
2382 >                    if (root.status >= 0)
2383                          helpComplete(root, SHARED_QUEUE);
2384                      break;
2385                  }
# Line 2360 | Line 2394 | public class ForkJoinPool extends Abstra
2394      static void externalHelpJoin(ForkJoinTask<?> t) {
2395          // Some hard-to-avoid overlap with tryExternalUnpush
2396          ForkJoinPool p; WorkQueue[] ws; WorkQueue q, w; Submitter z;
2397 <        ForkJoinTask<?>[] a;  int m, s, n; long j;
2397 >        ForkJoinTask<?>[] a;  int m, s, n;
2398          if (t != null &&
2399              (z = submitters.get()) != null &&
2400              (p = commonPool) != null &&
2401              (ws = p.workQueues) != null &&
2402              (m = ws.length - 1) >= 0 &&
2403              (q = ws[m & z.seed & SQMASK]) != null &&
2404 <            (a = q.array) != null &&
2405 <            t.status >= 0) {
2406 <            if ((s = q.top) != q.base &&
2407 <                U.getObjectVolatile
2408 <                (a, j = (((a.length - 1) & (s - 1)) << ASHIFT) + ABASE) == t &&
2409 <                U.compareAndSwapInt(q, QLOCK, 0, 1)) {
2410 <                if (q.array == a && q.top == s &&
2411 <                    U.compareAndSwapObject(a, j, t, null)) {
2412 <                    q.top = s - 1;
2413 <                    q.qlock = 0;
2414 <                    t.doExec();
2404 >            (a = q.array) != null) {
2405 >            int am = a.length - 1;
2406 >            if ((s = q.top) != q.base) {
2407 >                long j = ((am & (s - 1)) << ASHIFT) + ABASE;
2408 >                if (U.getObject(a, j) == t &&
2409 >                    U.compareAndSwapInt(q, QLOCK, 0, 1)) {
2410 >                    if (q.array == a && q.top == s &&
2411 >                        U.compareAndSwapObject(a, j, t, null)) {
2412 >                        q.top = s - 1;
2413 >                        q.qlock = 0;
2414 >                        t.doExec();
2415 >                    }
2416 >                    else
2417 >                        q.qlock = 0;
2418                  }
2382                else
2383                    q.qlock = 0;
2419              }
2420              if (t.status >= 0) {
2421                  if (t instanceof CountedCompleter)
2422                      p.externalHelpComplete(q, t);
2423                  else
2424 <                    p.helpSignal(t, q.poolIndex);
2424 >                    p.helpSignal(t, q.poolIndex, false);
2425              }
2426          }
2427      }
# Line 2834 | Line 2869 | public class ForkJoinPool extends Abstra
2869          WorkQueue[] ws; WorkQueue w;
2870          if ((ws = workQueues) != null) {
2871              for (int i = 0; i < ws.length; i += 2) {
2872 <                if ((w = ws[i]) != null && w.queueSize() != 0)
2872 >                if ((w = ws[i]) != null && !w.isEmpty())
2873                      return true;
2874              }
2875          }
# Line 3156 | Line 3191 | public class ForkJoinPool extends Abstra
3191          if (t instanceof ForkJoinWorkerThread) {
3192              ForkJoinPool p = ((ForkJoinWorkerThread)t).pool;
3193              while (!blocker.isReleasable()) { // variant of helpSignal
3194 <                WorkQueue[] ws; WorkQueue q; int m, n, u;
3194 >                WorkQueue[] ws; WorkQueue q; int m, u;
3195                  if ((ws = p.workQueues) != null && (m = ws.length - 1) >= 0) {
3196                      for (int i = 0; i <= m; ++i) {
3197                          if (blocker.isReleasable())
3198                              return;
3199 <                        if ((q = ws[i]) != null && (n = q.queueSize()) > 0) {
3200 <                            p.signalWork(q, n);
3199 >                        if ((q = ws[i]) != null && q.base - q.top < 0) {
3200 >                            p.signalWork(q);
3201                              if ((u = (int)(p.ctl >>> 32)) >= 0 ||
3202                                  (u >> UAC_SHIFT) >= 0)
3203                                  break;
# Line 3241 | Line 3276 | public class ForkJoinPool extends Abstra
3276          submitters = new ThreadLocal<Submitter>();
3277          ForkJoinWorkerThreadFactory fac = defaultForkJoinWorkerThreadFactory =
3278              new DefaultForkJoinWorkerThreadFactory();
3279 +        modifyThreadPermission = new RuntimePermission("modifyThread");
3280 +
3281          /*
3282           * Establish common pool parameters.  For extra caution,
3283           * computations to set up common pool state are here; the
# Line 3276 | Line 3313 | public class ForkJoinPool extends Abstra
3313          long ct = ((np << AC_SHIFT) & AC_MASK) | ((np << TC_SHIFT) & TC_MASK);
3314  
3315          commonPool = new ForkJoinPool(par, ct, fac, handler);
3279        modifyThreadPermission = new RuntimePermission("modifyThread");
3316      }
3317  
3318      /**

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines