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

Comparing jsr166/src/main/java/util/concurrent/ThreadPoolExecutor.java (file contents):
Revision 1.138 by jsr166, Sun Jan 13 17:52:19 2013 UTC vs.
Revision 1.139 by jsr166, Mon Jan 21 05:24:39 2013 UTC

# Line 999 | Line 999 | public class ThreadPoolExecutor extends
999       * 4. This worker timed out waiting for a task, and timed-out
1000       *    workers are subject to termination (that is,
1001       *    {@code allowCoreThreadTimeOut || workerCount > corePoolSize})
1002 <     *    both before and after the timed wait.
1002 >     *    both before and after the timed wait, and if the queue is
1003 >     *    non-empty, this worker is not the last thread in the pool.
1004       *
1005       * @return task, or null if the worker must exit, in which case
1006       *         workerCount is decremented
# Line 1007 | Line 1008 | public class ThreadPoolExecutor extends
1008      private Runnable getTask() {
1009          boolean timedOut = false; // Did the last poll() time out?
1010  
1010        retry:
1011          for (;;) {
1012              int c = ctl.get();
1013              int rs = runStateOf(c);
# Line 1018 | Line 1018 | public class ThreadPoolExecutor extends
1018                  return null;
1019              }
1020  
1021 <            boolean timed;      // Are workers subject to culling?
1021 >            int wc = workerCountOf(c);
1022  
1023 <            for (;;) {
1024 <                int wc = workerCountOf(c);
1025 <                timed = allowCoreThreadTimeOut || wc > corePoolSize;
1023 >            // Are workers subject to culling?
1024 >            boolean timed = allowCoreThreadTimeOut || wc > corePoolSize;
1025  
1026 <                if (wc <= maximumPoolSize && ! (timedOut && timed))
1027 <                    break;
1026 >            if ((wc > maximumPoolSize || (timed && timedOut))
1027 >                && (wc > 1 || workQueue.isEmpty())) {
1028                  if (compareAndDecrementWorkerCount(c))
1029                      return null;
1030 <                c = ctl.get();  // Re-read ctl
1032 <                if (runStateOf(c) != rs)
1033 <                    continue retry;
1034 <                // else CAS failed due to workerCount change; retry inner loop
1030 >                continue;
1031              }
1032  
1033              try {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines