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.7 by jsr166, Mon Jul 20 21:45:06 2009 UTC vs.
Revision 1.8 by jsr166, Mon Jul 20 21:54:51 2009 UTC

# Line 28 | Line 28 | import java.lang.reflect.*;
28   * most tasks spawn other subtasks (as do most ForkJoinTasks), as well
29   * as the mixed execution of some plain Runnable- or Callable- based
30   * activities along with ForkJoinTasks. When setting
31 < * <tt>setAsyncMode</tt>, a ForkJoinPools may also be appropriate for
31 > * {@code setAsyncMode}, a ForkJoinPools may also be appropriate for
32   * use with fine-grained tasks that are never joined. Otherwise, other
33   * ExecutorService implementations are typically more appropriate
34   * choices.
# Line 38 | Line 38 | import java.lang.reflect.*;
38   * adding, suspending, or resuming threads, even if some tasks are
39   * waiting to join others. However, no such adjustments are performed
40   * in the face of blocked IO or other unmanaged synchronization. The
41 < * nested <code>ManagedBlocker</code> interface enables extension of
41 > * nested {@code ManagedBlocker} interface enables extension of
42   * the kinds of synchronization accommodated.  The target parallelism
43 < * level may also be changed dynamically (<code>setParallelism</code>)
43 > * level may also be changed dynamically ({@code setParallelism})
44   * and thread construction can be limited using methods
45 < * <code>setMaximumPoolSize</code> and/or
46 < * <code>setMaintainsParallelism</code>.
45 > * {@code setMaximumPoolSize} and/or
46 > * {@code setMaintainsParallelism}.
47   *
48   * <p>In addition to execution and lifecycle control methods, this
49   * class provides status check methods (for example
50 < * <code>getStealCount</code>) that are intended to aid in developing,
50 > * {@code getStealCount}) that are intended to aid in developing,
51   * tuning, and monitoring fork/join applications. Also, method
52 < * <code>toString</code> returns indications of pool state in a
52 > * {@code toString} returns indications of pool state in a
53   * convenient form for informal monitoring.
54   *
55   * <p><b>Implementation notes</b>: This implementation restricts the
# Line 333 | Line 333 | public class ForkJoinPool extends Abstra
333       * @throws SecurityException if a security manager exists and
334       *         the caller is not permitted to modify threads
335       *         because it does not hold {@link
336 <     *         java.lang.RuntimePermission}<code>("modifyThread")</code>,
336 >     *         java.lang.RuntimePermission}{@code ("modifyThread")},
337       */
338      public ForkJoinPool() {
339          this(Runtime.getRuntime().availableProcessors(),
# Line 349 | Line 349 | public class ForkJoinPool extends Abstra
349       * @throws SecurityException if a security manager exists and
350       *         the caller is not permitted to modify threads
351       *         because it does not hold {@link
352 <     *         java.lang.RuntimePermission}<code>("modifyThread")</code>,
352 >     *         java.lang.RuntimePermission}{@code ("modifyThread")},
353       */
354      public ForkJoinPool(int parallelism) {
355          this(parallelism, defaultForkJoinWorkerThreadFactory);
# Line 364 | Line 364 | public class ForkJoinPool extends Abstra
364       * @throws SecurityException if a security manager exists and
365       *         the caller is not permitted to modify threads
366       *         because it does not hold {@link
367 <     *         java.lang.RuntimePermission}<code>("modifyThread")</code>,
367 >     *         java.lang.RuntimePermission}{@code ("modifyThread")},
368       */
369      public ForkJoinPool(ForkJoinWorkerThreadFactory factory) {
370          this(Runtime.getRuntime().availableProcessors(), factory);
# Line 381 | Line 381 | public class ForkJoinPool extends Abstra
381       * @throws SecurityException if a security manager exists and
382       *         the caller is not permitted to modify threads
383       *         because it does not hold {@link
384 <     *         java.lang.RuntimePermission}<code>("modifyThread")</code>,
384 >     *         java.lang.RuntimePermission}{@code ("modifyThread")},
385       */
386      public ForkJoinPool(int parallelism, ForkJoinWorkerThreadFactory factory) {
387          if (parallelism <= 0 || parallelism > MAX_THREADS)
# Line 689 | Line 689 | public class ForkJoinPool extends Abstra
689       * @throws SecurityException if a security manager exists and
690       *         the caller is not permitted to modify threads
691       *         because it does not hold {@link
692 <     *         java.lang.RuntimePermission}<code>("modifyThread")</code>,
692 >     *         java.lang.RuntimePermission}{@code ("modifyThread")},
693       */
694      public Thread.UncaughtExceptionHandler
695          setUncaughtExceptionHandler(Thread.UncaughtExceptionHandler h) {
# Line 723 | Line 723 | public class ForkJoinPool extends Abstra
723       * @throws SecurityException if a security manager exists and
724       *         the caller is not permitted to modify threads
725       *         because it does not hold {@link
726 <     *         java.lang.RuntimePermission}<code>("modifyThread")</code>,
726 >     *         java.lang.RuntimePermission}{@code ("modifyThread")},
727       */
728      public void setParallelism(int parallelism) {
729          checkPermission();
# Line 758 | Line 758 | public class ForkJoinPool extends Abstra
758      /**
759       * Returns the number of worker threads that have started but not
760       * yet terminated.  This result returned by this method may differ
761 <     * from <code>getParallelism</code> when threads are created to
761 >     * from {@code getParallelism} when threads are created to
762       * maintain parallelism when others are cooperatively blocked.
763       *
764       * @return the number of worker threads
# Line 953 | Line 953 | public class ForkJoinPool extends Abstra
953      /**
954       * Returns true if there are any tasks submitted to this pool
955       * that have not yet begun executing.
956 <     * @return <code>true</code> if there are any queued submissions.
956 >     * @return {@code true} if there are any queued submissions.
957       */
958      public boolean hasQueuedSubmissions() {
959          return !submissionQueue.isEmpty();
# Line 977 | Line 977 | public class ForkJoinPool extends Abstra
977       * to be invoked only when the pool is known to be
978       * quiescent. Invocations at other times may not remove all
979       * tasks. A failure encountered while attempting to add elements
980 <     * to collection <tt>c</tt> may result in elements being in
980 >     * to collection {@code c} may result in elements being in
981       * neither, either or both collections when the associated
982       * exception is thrown.  The behavior of this operation is
983       * undefined if the specified collection is modified while the
# Line 1045 | Line 1045 | public class ForkJoinPool extends Abstra
1045       * @throws SecurityException if a security manager exists and
1046       *         the caller is not permitted to modify threads
1047       *         because it does not hold {@link
1048 <     *         java.lang.RuntimePermission}<code>("modifyThread")</code>,
1048 >     *         java.lang.RuntimePermission}{@code ("modifyThread")},
1049       */
1050      public void shutdown() {
1051          checkPermission();
# Line 1061 | Line 1061 | public class ForkJoinPool extends Abstra
1061       * method may or may not be rejected. Unlike some other executors,
1062       * this method cancels rather than collects non-executed tasks
1063       * upon termination, so always returns an empty list. However, you
1064 <     * can use method <code>drainTasksTo</code> before invoking this
1064 >     * can use method {@code drainTasksTo} before invoking this
1065       * method to transfer unexecuted tasks to another collection.
1066       * @return an empty list
1067       * @throws SecurityException if a security manager exists and
1068       *         the caller is not permitted to modify threads
1069       *         because it does not hold {@link
1070 <     *         java.lang.RuntimePermission}<code>("modifyThread")</code>,
1070 >     *         java.lang.RuntimePermission}{@code ("modifyThread")},
1071       */
1072      public List<Runnable> shutdownNow() {
1073          checkPermission();
# Line 1076 | Line 1076 | public class ForkJoinPool extends Abstra
1076      }
1077  
1078      /**
1079 <     * Returns <code>true</code> if all tasks have completed following shut down.
1079 >     * Returns {@code true} if all tasks have completed following shut down.
1080       *
1081 <     * @return <code>true</code> if all tasks have completed following shut down
1081 >     * @return {@code true} if all tasks have completed following shut down
1082       */
1083      public boolean isTerminated() {
1084          return runStateOf(runControl) == TERMINATED;
1085      }
1086  
1087      /**
1088 <     * Returns <code>true</code> if the process of termination has
1088 >     * Returns {@code true} if the process of termination has
1089       * commenced but possibly not yet completed.
1090       *
1091 <     * @return <code>true</code> if terminating
1091 >     * @return {@code true} if terminating
1092       */
1093      public boolean isTerminating() {
1094          return runStateOf(runControl) >= TERMINATING;
1095      }
1096  
1097      /**
1098 <     * Returns <code>true</code> if this pool has been shut down.
1098 >     * Returns {@code true} if this pool has been shut down.
1099       *
1100 <     * @return <code>true</code> if this pool has been shut down
1100 >     * @return {@code true} if this pool has been shut down
1101       */
1102      public boolean isShutdown() {
1103          return runStateOf(runControl) >= SHUTDOWN;
# Line 1110 | Line 1110 | public class ForkJoinPool extends Abstra
1110       *
1111       * @param timeout the maximum time to wait
1112       * @param unit the time unit of the timeout argument
1113 <     * @return <code>true</code> if this executor terminated and
1114 <     *         <code>false</code> if the timeout elapsed before termination
1113 >     * @return {@code true} if this executor terminated and
1114 >     *         {@code false} if the timeout elapsed before termination
1115       * @throws InterruptedException if interrupted while waiting
1116       */
1117      public boolean awaitTermination(long timeout, TimeUnit unit)
# Line 1690 | Line 1690 | public class ForkJoinPool extends Abstra
1690      /**
1691       * Interface for extending managed parallelism for tasks running
1692       * in ForkJoinPools. A ManagedBlocker provides two methods.
1693 <     * Method <code>isReleasable</code> must return true if blocking is not
1694 <     * necessary. Method <code>block</code> blocks the current thread
1693 >     * Method {@code isReleasable} must return true if blocking is not
1694 >     * necessary. Method {@code block} blocks the current thread
1695       * if necessary (perhaps internally invoking isReleasable before
1696       * actually blocking.).
1697       * <p>For example, here is a ManagedBlocker based on a
# Line 1734 | Line 1734 | public class ForkJoinPool extends Abstra
1734       * is a ForkJoinWorkerThread, this method possibly arranges for a
1735       * spare thread to be activated if necessary to ensure parallelism
1736       * while the current thread is blocked.  If
1737 <     * <code>maintainParallelism</code> is true and the pool supports
1737 >     * {@code maintainParallelism} is true and the pool supports
1738       * it ({@link #getMaintainsParallelism}), this method attempts to
1739       * maintain the pool's nominal parallelism. Otherwise if activates
1740       * a thread only if necessary to avoid complete starvation. This

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines