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.113 by jsr166, Thu Sep 7 20:01:04 2006 UTC vs.
Revision 1.114 by dl, Tue Oct 3 00:21:08 2006 UTC

# Line 1193 | Line 1193 | public class ThreadPoolExecutor extends
1193          }
1194          if (runStateOf(c) == RUNNING && workQueue.offer(command)) {
1195              int recheck = ctl.get();
1196 <            if (runStateOf(recheck) != RUNNING && remove(command))
1196 >            if (runStateOf(recheck) >= STOP && remove(command))
1197                  reject(command);
1198              else if (workerCountOf(recheck) == 0)
1199                  addWorker(null, false);
# Line 1564 | Line 1564 | public class ThreadPoolExecutor extends
1564       * @return true if the task was removed
1565       */
1566      public boolean remove(Runnable task) {
1567 <        boolean removed = workQueue.remove(task);
1568 <        tryTerminate(); // In case SHUTDOWN and now empty
1567 >        boolean removed;
1568 >        final ReentrantLock mainLock = this.mainLock;
1569 >        mainLock.lock();
1570 >        try {
1571 >            removed = workQueue.remove(task);
1572 >        } finally {
1573 >            mainLock.unlock();
1574 >        }
1575 >        if (removed)
1576 >            tryTerminate(); // In case SHUTDOWN and now empty
1577          return removed;
1578      }
1579  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines