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.87 by jsr166, Tue Jun 20 05:27:06 2006 UTC vs.
Revision 1.88 by jsr166, Tue Jun 20 05:51:31 2006 UTC

# Line 306 | Line 306 | public class ThreadPoolExecutor extends
306       * read outside of locked regions. (Also, the workers Set is
307       * accessed only under lock).
308       *
309 <     * The other fields representng user control parameters do not
309 >     * The other fields representing user control parameters do not
310       * affect execution invariants, so are declared volatile and
311       * allowed to change (via user methods) asynchronously with
312       * execution. These fields include: allowCoreThreadTimeOut,
313       * keepAliveTime, the rejected execution handler, and
314 <     * threadfactory are not updated within locks
314 >     * threadFactory are not updated within locks.
315       *
316       * The extensive use of volatiles here enables the most
317       * performance-critical actions, such as enqueuing and dequeing
# Line 335 | Line 335 | public class ThreadPoolExecutor extends
335       * time, but need not hit each state. The transitions are:
336       *
337       * RUNNING -> SHUTDOWN
338 <     *    On invocation of shutdown(), perhaps implicity in finalize()
338 >     *    On invocation of shutdown(), perhaps implicitly in finalize()
339       * (RUNNING or SHUTDOWN) -> STOP
340       *    On invocation of shutdownNow()
341       * SHUTDOWN -> TERMINATED
# Line 372 | Line 372 | public class ThreadPoolExecutor extends
372      private final Condition termination = mainLock.newCondition();
373  
374      /**
375 <     * Set containing all worker threads in pool. Accessed onl when
375 >     * Set containing all worker threads in pool. Accessed only when
376       * holding mainLock.
377       */
378      private final HashSet<Worker> workers = new HashSet<Worker>();
# Line 615 | Line 615 | public class ThreadPoolExecutor extends
615       * 2. If a task can be successfully queued, then we are done, but
616       * still need to compensate for missing the fact that we should
617       * have added a thread (because existing ones died) or that
618 <     * shutdown occured since entry into this method. So we recheck
618 >     * shutdown occurred since entry into this method. So we recheck
619       * state to and if necessary (in ensureQueuedTaskHandled) roll
620       * back the enqueuing if shut down, or start a new thread if there
621       * are none.
# Line 685 | Line 685 | public class ThreadPoolExecutor extends
685       * and the pool is not shut down.
686       * @param firstTask the task the new thread should run first (or
687       * null if none)
688 <     * @return true if successful.
688 >     * @return true if successful
689       */
690      private boolean addIfUnderCorePoolSize(Runnable firstTask) {
691          Thread t = null;
# Line 709 | Line 709 | public class ThreadPoolExecutor extends
709       * and pool is not shut down.
710       * @param firstTask the task the new thread should run first (or
711       * null if none)
712 <     * @return true if successful.
712 >     * @return true if successful
713       */
714      private boolean addIfUnderMaximumPoolSize(Runnable firstTask) {
715          Thread t = null;
# Line 771 | Line 771 | public class ThreadPoolExecutor extends
771       * Worker threads.
772       *
773       * Worker threads can start out life either with an initial first
774 <     * task, oo without one. Normally, they are started with a first
774 >     * task, or without one. Normally, they are started with a first
775       * task. This enables execute(), etc to bypass queuing when there
776       * are fewer than corePoolSize threads (in which case we always
777       * start one), or when the queue is full.(in which case we must
# Line 926 | Line 926 | public class ThreadPoolExecutor extends
926       * before giving up, and (2) interrupting other workers upon
927       * shutdown, so they can recheck state. All other user-based state
928       * changes (to allowCoreThreadTimeOut etc) are OK even when
929 <     * perfromed asynchronously wrt getTask.
929 >     * performed asynchronously wrt getTask.
930       *
931       * @return the task
932       */
# Line 952 | Line 952 | public class ThreadPoolExecutor extends
952                  }
953                  // Else retry
954              } catch (InterruptedException ie) {
955 <                // On interruption, re-check runstate
955 >                // On interruption, re-check runState
956              }
957          }
958      }
# Line 1016 | Line 1016 | public class ThreadPoolExecutor extends
1016  
1017      /**
1018       * Transitions to TERMINATED state if either (SHUTDOWN and pool
1019 <     * and queue empty) or (STOP and pool empty), otherwisem unless
1019 >     * and queue empty) or (STOP and pool empty), otherwise unless
1020       * stopped, ensuring that there is at least one live thread to
1021       * handle queued tasks.
1022       *
# Line 1056 | Line 1056 | public class ThreadPoolExecutor extends
1056      public void shutdown() {
1057          /*
1058           * Conceptually, shutdown is just a matter of changing the
1059 <         * runsState to SHUTDOWN, and then interrupting any worker
1059 >         * runState to SHUTDOWN, and then interrupting any worker
1060           * threads that might be blocked in getTask() to wake them up
1061           * so they can exit. Then, if there happen not to be any
1062           * threads or tasks, we can directly terminate pool via
# Line 1373 | Line 1373 | public class ThreadPoolExecutor extends
1373       * Starts all core threads, causing them to idly wait for work. This
1374       * overrides the default policy of starting core threads only when
1375       * new tasks are executed.
1376 <     * @return the number of threads started.
1376 >     * @return the number of threads started
1377       */
1378      public int prestartAllCoreThreads() {
1379          int n = 0;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines