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

Comparing jsr166/src/jsr166y/ForkJoinTask.java (file contents):
Revision 1.29 by jsr166, Sun Aug 2 17:19:24 2009 UTC vs.
Revision 1.34 by dl, Tue Aug 4 11:44:33 2009 UTC

# Line 12 | Line 12 | import java.io.Serializable;
12   import java.util.Collection;
13   import java.util.Collections;
14   import java.util.List;
15 + import java.util.RandomAccess;
16   import java.util.Map;
17   import java.util.WeakHashMap;
18  
# Line 54 | Line 55 | import java.util.WeakHashMap;
55   * restriction is in part enforced by not permitting checked
56   * exceptions such as {@code IOExceptions} to be thrown. However,
57   * computations may still encounter unchecked exceptions, that are
58 < * rethrown to callers attempting join them. These exceptions may
58 > * rethrown to callers attempting to join them. These exceptions may
59   * additionally include RejectedExecutionExceptions stemming from
60   * internal resource exhaustion such as failure to allocate internal
61   * task queues.
# Line 85 | Line 86 | import java.util.WeakHashMap;
86   * established in a constructor, and then defines a {@code compute}
87   * method that somehow uses the control methods supplied by this base
88   * class. While these methods have {@code public} access (to allow
89 < * instances of different task subclasses to call each others
89 > * instances of different task subclasses to call each other's
90   * methods), some of them may only be called from within other
91   * ForkJoinTasks (as may be determined using method {@link
92   * #inForkJoinPool}).  Attempts to invoke them in other contexts
93   * result in exceptions or errors, possibly including
94   * ClassCastException.
95   *
96 < * <p>Most base support methods are {@code final} because their
97 < * implementations are intrinsically tied to the underlying
98 < * lightweight task scheduling framework, and so cannot be overridden.
99 < * Developers creating new basic styles of fork/join processing should
100 < * minimally implement {@code protected} methods
101 < * {@link #exec}, {@link #setRawResult}, and
102 < * {@link #getRawResult}, while also introducing an abstract
103 < * computational method that can be implemented in its subclasses,
104 < * possibly relying on other {@code protected} methods provided
104 < * by this class.
96 > * <p>Most base support methods are {@code final}, to prevent
97 > * overriding of implementations that are intrinsically tied to the
98 > * underlying lightweight task scheduling framework.  Developers
99 > * creating new basic styles of fork/join processing should minimally
100 > * implement {@code protected} methods {@link #exec}, {@link
101 > * #setRawResult}, and {@link #getRawResult}, while also introducing
102 > * an abstract computational method that can be implemented in its
103 > * subclasses, possibly relying on other {@code protected} methods
104 > * provided by this class.
105   *
106   * <p>ForkJoinTasks should perform relatively small amounts of
107 < * computations, otherwise splitting into smaller tasks. As a very
108 < * rough rule of thumb, a task should perform more than 100 and less
109 < * than 10000 basic computational steps. If tasks are too big, then
110 < * parallelism cannot improve throughput. If too small, then memory
111 < * and internal task maintenance overhead may overwhelm processing.
107 > * computation. Large tasks should be split into smaller subtasks,
108 > * usually via recursive decomposition. As a very rough rule of thumb,
109 > * a task should perform more than 100 and less than 10000 basic
110 > * computational steps. If tasks are too big, then parallelism cannot
111 > * improve throughput. If too small, then memory and internal task
112 > * maintenance overhead may overwhelm processing.
113   *
114   * <p>This class provides {@code adapt} methods for {@link
115   * java.lang.Runnable} and {@link java.util.concurrent.Callable}, that
116   * may be of use when mixing execution of ForkJoinTasks with other
117   * kinds of tasks. When all tasks are of this form, consider using a
118 < * pool in {@link ForkJoinPool#setAsyncMode}.
118 > * pool in {@link ForkJoinPool#setAsyncMode async mode}.
119   *
120 < * <p>ForkJoinTasks are {@code Serializable}, which enables them
121 < * to be used in extensions such as remote execution frameworks. It is
122 < * in general sensible to serialize tasks only before or after, but
123 < * not during execution. Serialization is not relied on during
123 < * execution itself.
120 > * <p>ForkJoinTasks are {@code Serializable}, which enables them to be
121 > * used in extensions such as remote execution frameworks. It is
122 > * sensible to serialize tasks only before or after, but not during,
123 > * execution. Serialization is not relied on during execution itself.
124   *
125   * @since 1.7
126   * @author Doug Lea
# Line 382 | Line 382 | public abstract class ForkJoinTask<V> im
382       */
383      private V reportFutureResult()
384          throws ExecutionException, InterruptedException {
385 +        if (Thread.interrupted())
386 +            throw new InterruptedException();
387          int s = status & COMPLETION_MASK;
388          if (s < NORMAL) {
389              Throwable ex;
# Line 389 | Line 391 | public abstract class ForkJoinTask<V> im
391                  throw new CancellationException();
392              if (s == EXCEPTIONAL && (ex = exceptionMap.get(this)) != null)
393                  throw new ExecutionException(ex);
392            if (Thread.interrupted())
393                throw new InterruptedException();
394          }
395          return getRawResult();
396      }
# Line 401 | Line 401 | public abstract class ForkJoinTask<V> im
401       */
402      private V reportTimedFutureResult()
403          throws InterruptedException, ExecutionException, TimeoutException {
404 +        if (Thread.interrupted())
405 +            throw new InterruptedException();
406          Throwable ex;
407          int s = status & COMPLETION_MASK;
408          if (s == NORMAL)
# Line 409 | Line 411 | public abstract class ForkJoinTask<V> im
411              throw new CancellationException();
412          if (s == EXCEPTIONAL && (ex = exceptionMap.get(this)) != null)
413              throw new ExecutionException(ex);
412        if (Thread.interrupted())
413            throw new InterruptedException();
414          throw new TimeoutException();
415      }
416  
# Line 496 | Line 496 | public abstract class ForkJoinTask<V> im
496      /**
497       * Arranges to asynchronously execute this task.  While it is not
498       * necessarily enforced, it is a usage error to fork a task more
499 <     * than once unless it has completed and been reinitialized.  This
500 <     * method may be invoked only from within ForkJoinTask
501 <     * computations (as may be determined using method {@link
502 <     * #inForkJoinPool}). Attempts to invoke in other contexts result
503 <     * in exceptions or errors, possibly including ClassCastException.
499 >     * than once unless it has completed and been reinitialized.
500 >     *
501 >     * <p>This method may be invoked only from within {@code
502 >     * ForkJoinTask} computations (as may be determined using method
503 >     * {@link #inForkJoinPool}).  Attempts to invoke in other contexts
504 >     * result in exceptions or errors, possibly including {@code
505 >     * ClassCastException}.
506       *
507 <     * @return {@code this}, to simplify usage.
507 >     * @return {@code this}, to simplify usage
508       */
509      public final ForkJoinTask<V> fork() {
510          ((ForkJoinWorkerThread) Thread.currentThread())
# Line 512 | Line 514 | public abstract class ForkJoinTask<V> im
514  
515      /**
516       * Returns the result of the computation when it is ready.
517 <     * This method differs from {@code get} in that abnormal
518 <     * completion results in RuntimeExceptions or Errors, not
519 <     * ExecutionExceptions.
517 >     * This method differs from {@link #get()} in that
518 >     * abnormal completion results in {@code RuntimeException} or
519 >     * {@code Error}, not {@code ExecutionException}.
520       *
521       * @return the computed result
522       */
# Line 527 | Line 529 | public abstract class ForkJoinTask<V> im
529  
530      /**
531       * Commences performing this task, awaits its completion if
532 <     * necessary, and return its result.
532 >     * necessary, and return its result, or throws an (unchecked)
533 >     * exception if the underlying computation did so.
534       *
532     * @throws Throwable (a RuntimeException, Error, or unchecked
533     * exception) if the underlying computation did so
535       * @return the computed result
536       */
537      public final V invoke() {
# Line 542 | Line 543 | public abstract class ForkJoinTask<V> im
543  
544      /**
545       * Forks the given tasks, returning when {@code isDone} holds for
546 <     * each task or an exception is encountered. This method may be
547 <     * invoked only from within ForkJoinTask computations (as may be
548 <     * determined using method {@link #inForkJoinPool}). Attempts to
549 <     * invoke in other contexts result in exceptions or errors,
550 <     * possibly including ClassCastException.
546 >     * each task or an (unchecked) exception is encountered, in which
547 >     * case the exception is rethrown.  If more than one task
548 >     * encounters an exception, then this method throws any one of
549 >     * these exceptions.  The individual status of each task may be
550 >     * checked using {@link #getException()} and related methods.
551 >     *
552 >     * <p>This method may be invoked only from within {@code
553 >     * ForkJoinTask} computations (as may be determined using method
554 >     * {@link #inForkJoinPool}).  Attempts to invoke in other contexts
555 >     * result in exceptions or errors, possibly including {@code
556 >     * ClassCastException}.
557       *
558       * @param t1 the first task
559       * @param t2 the second task
560       * @throws NullPointerException if any task is null
554     * @throws RuntimeException or Error if a task did so
561       */
562 <    public static void invokeAll(ForkJoinTask<?>t1, ForkJoinTask<?> t2) {
562 >    public static void invokeAll(ForkJoinTask<?> t1, ForkJoinTask<?> t2) {
563          t2.fork();
564          t1.invoke();
565          t2.join();
# Line 561 | Line 567 | public abstract class ForkJoinTask<V> im
567  
568      /**
569       * Forks the given tasks, returning when {@code isDone} holds for
570 <     * each task or an exception is encountered. If any task
571 <     * encounters an exception, others may be, but are not guaranteed
572 <     * to be, cancelled.  This method may be invoked only from within
573 <     * ForkJoinTask computations (as may be determined using method
574 <     * {@link #inForkJoinPool}). Attempts to invoke in other contexts
575 <     * result in exceptions or errors, possibly including
576 <     * ClassCastException.
577 <     *
578 <     * Overloadings of this method exist for the special cases
579 <     * of one to four arguments.
570 >     * each task or an (unchecked) exception is encountered, in which
571 >     * case the exception is rethrown. If any task encounters an
572 >     * exception, others may be, but are not guaranteed to be,
573 >     * cancelled.  If more than one task encounters an exception, then
574 >     * this method throws any one of these exceptions.  The individual
575 >     * status of each task may be checked using {@link #getException()}
576 >     * and related methods.
577 >     *
578 >     * <p>This method may be invoked only from within {@code
579 >     * ForkJoinTask} computations (as may be determined using method
580 >     * {@link #inForkJoinPool}).  Attempts to invoke in other contexts
581 >     * result in exceptions or errors, possibly including {@code
582 >     * ClassCastException}.
583       *
584       * @param tasks the tasks
585 <     * @throws NullPointerException if tasks or any element are null
577 <     * @throws RuntimeException or Error if any task did so
585 >     * @throws NullPointerException if any task is null
586       */
587      public static void invokeAll(ForkJoinTask<?>... tasks) {
588          Throwable ex = null;
# Line 610 | Line 618 | public abstract class ForkJoinTask<V> im
618      }
619  
620      /**
621 <     * Forks all tasks in the collection, returning when {@code
622 <     * isDone} holds for each task or an exception is encountered. If
623 <     * any task encounters an exception, others may be, but are not
624 <     * guaranteed to be, cancelled.  This method may be invoked only
625 <     * from within ForkJoinTask computations (as may be determined
626 <     * using method {@link #inForkJoinPool}). Attempts to invoke in
627 <     * other contexts result in exceptions or errors, possibly
628 <     * including ClassCastException.
621 >     * Forks all tasks in the specified collection, returning when
622 >     * {@code isDone} holds for each task or an (unchecked) exception
623 >     * is encountered.  If any task encounters an exception, others
624 >     * may be, but are not guaranteed to be, cancelled.  If more than
625 >     * one task encounters an exception, then this method throws any
626 >     * one of these exceptions.  The individual status of each task
627 >     * may be checked using {@link #getException()} and related
628 >     * methods.  The behavior of this operation is undefined if the
629 >     * specified collection is modified while the operation is in
630 >     * progress.
631 >     *
632 >     * <p>This method may be invoked only from within {@code
633 >     * ForkJoinTask} computations (as may be determined using method
634 >     * {@link #inForkJoinPool}).  Attempts to invoke in other contexts
635 >     * result in exceptions or errors, possibly including {@code
636 >     * ClassCastException}.
637       *
638       * @param tasks the collection of tasks
639       * @return the tasks argument, to simplify usage
640       * @throws NullPointerException if tasks or any element are null
625     * @throws RuntimeException or Error if any task did so
641       */
642      public static <T extends ForkJoinTask<?>> Collection<T> invokeAll(Collection<T> tasks) {
643 <        if (!(tasks instanceof List<?>)) {
643 >        if (!(tasks instanceof RandomAccess) || !(tasks instanceof List<?>)) {
644              invokeAll(tasks.toArray(new ForkJoinTask<?>[tasks.size()]));
645              return tasks;
646          }
# Line 666 | Line 681 | public abstract class ForkJoinTask<V> im
681      }
682  
683      /**
684 <     * Returns {@code true} if the computation performed by this task
685 <     * has completed (or has been cancelled).
686 <     *
687 <     * @return {@code true} if this computation has completed
688 <     */
689 <    public final boolean isDone() {
690 <        return status < 0;
676 <    }
677 <
678 <    /**
679 <     * Returns {@code true} if this task was cancelled.
680 <     *
681 <     * @return {@code true} if this task was cancelled
682 <     */
683 <    public final boolean isCancelled() {
684 <        return (status & COMPLETION_MASK) == CANCELLED;
685 <    }
686 <
687 <    /**
688 <     * Asserts that the results of this task's computation will not be
689 <     * used. If a cancellation occurs before attempting to execute this
690 <     * task, execution will be suppressed, {@link #isCancelled}
691 <     * will report true, and {@link #join} will result in a
692 <     * {@code CancellationException} being thrown. Otherwise, when
693 <     * cancellation races with completion, there are no guarantees
694 <     * about whether {@code isCancelled} will report {@code true},
695 <     * whether {@code join} will return normally or via an exception,
696 <     * or whether these behaviors will remain consistent upon repeated
697 <     * invocation.
684 >     * Attempts to cancel execution of this task. This attempt will
685 >     * fail if the task has already completed, has already been
686 >     * cancelled, or could not be cancelled for some other reason. If
687 >     * successful, and this task has not started when cancel is
688 >     * called, execution of this task is suppressed, {@link
689 >     * #isCancelled} will report true, and {@link #join} will result
690 >     * in a {@code CancellationException} being thrown.
691       *
692       * <p>This method may be overridden in subclasses, but if so, must
693       * still ensure that these minimal properties hold. In particular,
# Line 706 | Line 699 | public abstract class ForkJoinTask<V> im
699       * invoke {@link #completeExceptionally}.
700       *
701       * @param mayInterruptIfRunning this value is ignored in the
702 <     * default implementation because tasks are not in general
702 >     * default implementation because tasks are not
703       * cancelled via interruption
704       *
705       * @return {@code true} if this task is now cancelled
# Line 717 | Line 710 | public abstract class ForkJoinTask<V> im
710      }
711  
712      /**
713 +     * Returns {@code true} if the computation performed by this task
714 +     * has completed (or has been cancelled).
715 +     *
716 +     * @return {@code true} if this computation has completed
717 +     */
718 +    public final boolean isDone() {
719 +        return status < 0;
720 +    }
721 +
722 +    /**
723 +     * Returns {@code true} if this task was cancelled.
724 +     *
725 +     * @return {@code true} if this task was cancelled
726 +     */
727 +    public final boolean isCancelled() {
728 +        return (status & COMPLETION_MASK) == CANCELLED;
729 +    }
730 +
731 +    /**
732       * Returns {@code true} if this task threw an exception or was cancelled.
733       *
734       * @return {@code true} if this task threw an exception or was cancelled
# Line 726 | Line 738 | public abstract class ForkJoinTask<V> im
738      }
739  
740      /**
741 +     * Returns {@code true} if this task completed without throwing an
742 +     * exception and was not cancelled.
743 +     *
744 +     * @return {@code true} if this task completed without throwing an
745 +     * exception and was not cancelled
746 +     */
747 +    public final boolean isCompletedNormally() {
748 +        return (status & COMPLETION_MASK) == NORMAL;
749 +    }
750 +
751 +    /**
752 +     * Returns {@code true} if this task threw an exception.
753 +     *
754 +     * @return {@code true} if this task threw an exception
755 +     */
756 +    public final boolean isCompletedExceptionally() {
757 +        return (status & COMPLETION_MASK) == EXCEPTIONAL;
758 +    }
759 +
760 +    /**
761       * Returns the exception thrown by the base computation, or a
762       * {@code CancellationException} if cancelled, or {@code null} if
763       * none or if the method has not yet completed.
# Line 806 | Line 838 | public abstract class ForkJoinTask<V> im
838       * there are no potential dependencies between continuation of the
839       * current task and that of any other task that might be executed
840       * while helping. (This usually holds for pure divide-and-conquer
841 <     * tasks). This method may be invoked only from within
842 <     * ForkJoinTask computations (as may be determined using method
843 <     * {@link #inForkJoinPool}). Attempts to invoke in other contexts
844 <     * result in exceptions or errors, possibly including
845 <     * ClassCastException.
841 >     * tasks).
842 >     *
843 >     * <p>This method may be invoked only from within {@code
844 >     * ForkJoinTask} computations (as may be determined using method
845 >     * {@link #inForkJoinPool}).  Attempts to invoke in other contexts
846 >     * result in exceptions or errors, possibly including {@code
847 >     * ClassCastException}.
848       *
849       * @return the computed result
850       */
# Line 823 | Line 857 | public abstract class ForkJoinTask<V> im
857  
858      /**
859       * Possibly executes other tasks until this task is ready.  This
860 <     * method may be invoked only from within ForkJoinTask
861 <     * computations (as may be determined using method {@link
862 <     * #inForkJoinPool}). Attempts to invoke in other contexts result
863 <     * in exceptions or errors, possibly including ClassCastException.
860 >     * method may be useful when processing collections of tasks when
861 >     * some have been cancelled or otherwise known to have aborted.
862 >     *
863 >     * <p>This method may be invoked only from within {@code
864 >     * ForkJoinTask} computations (as may be determined using method
865 >     * {@link #inForkJoinPool}).  Attempts to invoke in other contexts
866 >     * result in exceptions or errors, possibly including {@code
867 >     * ClassCastException}.
868       */
869      public final void quietlyHelpJoin() {
870          if (status >= 0) {
# Line 865 | Line 903 | public abstract class ForkJoinTask<V> im
903  
904      /**
905       * Possibly executes tasks until the pool hosting the current task
906 <     * {@link ForkJoinPool#isQuiescent}. This method may be of use in
907 <     * designs in which many tasks are forked, but none are explicitly
908 <     * joined, instead executing them until all are processed.  This
909 <     * method may be invoked only from within ForkJoinTask
910 <     * computations (as may be determined using method {@link
911 <     * #inForkJoinPool}). Attempts to invoke in other contexts result
912 <     * in exceptions or errors, possibly including ClassCastException.
906 >     * {@link ForkJoinPool#isQuiescent is quiescent}. This method may
907 >     * be of use in designs in which many tasks are forked, but none
908 >     * are explicitly joined, instead executing them until all are
909 >     * processed.
910 >     *
911 >     * <p>This method may be invoked only from within {@code
912 >     * ForkJoinTask} computations (as may be determined using method
913 >     * {@link #inForkJoinPool}).  Attempts to invoke in other contexts
914 >     * result in exceptions or errors, possibly including {@code
915 >     * ClassCastException}.
916       */
917      public static void helpQuiesce() {
918          ((ForkJoinWorkerThread) Thread.currentThread())
# Line 884 | Line 925 | public abstract class ForkJoinTask<V> im
925       * this task, but only if reuse occurs when this task has either
926       * never been forked, or has been forked, then completed and all
927       * outstanding joins of this task have also completed. Effects
928 <     * under any other usage conditions are not guaranteed, and are
929 <     * discouraged. This method may be useful when executing
928 >     * under any other usage conditions are not guaranteed.
929 >     * This method may be useful when executing
930       * pre-constructed trees of subtasks in loops.
931       */
932      public void reinitialize() {
# Line 924 | Line 965 | public abstract class ForkJoinTask<V> im
965       * by the current thread, and has not commenced executing in
966       * another thread.  This method may be useful when arranging
967       * alternative local processing of tasks that could have been, but
968 <     * were not, stolen. This method may be invoked only from within
969 <     * ForkJoinTask computations (as may be determined using method
970 <     * {@link #inForkJoinPool}). Attempts to invoke in other contexts
971 <     * result in exceptions or errors, possibly including
972 <     * ClassCastException.
968 >     * were not, stolen.
969 >     *
970 >     * <p>This method may be invoked only from within {@code
971 >     * ForkJoinTask} computations (as may be determined using method
972 >     * {@link #inForkJoinPool}).  Attempts to invoke in other contexts
973 >     * result in exceptions or errors, possibly including {@code
974 >     * ClassCastException}.
975       *
976       * @return {@code true} if unforked
977       */
# Line 941 | Line 984 | public abstract class ForkJoinTask<V> im
984       * Returns an estimate of the number of tasks that have been
985       * forked by the current worker thread but not yet executed. This
986       * value may be useful for heuristic decisions about whether to
987 <     * fork other tasks.  This method may be invoked only from within
988 <     * ForkJoinTask computations (as may be determined using method
989 <     * {@link #inForkJoinPool}). Attempts to invoke in other contexts
990 <     * result in exceptions or errors, possibly including
991 <     * ClassCastException.
987 >     * fork other tasks.
988 >     *
989 >     * <p>This method may be invoked only from within {@code
990 >     * ForkJoinTask} computations (as may be determined using method
991 >     * {@link #inForkJoinPool}).  Attempts to invoke in other contexts
992 >     * result in exceptions or errors, possibly including {@code
993 >     * ClassCastException}.
994 >     *
995       * @return the number of tasks
996       */
997      public static int getQueuedTaskCount() {
# Line 961 | Line 1007 | public abstract class ForkJoinTask<V> im
1007       * usages of ForkJoinTasks, at steady state, each worker should
1008       * aim to maintain a small constant surplus (for example, 3) of
1009       * tasks, and to process computations locally if this threshold is
1010 <     * exceeded.  This method may be invoked only from within
1011 <     * ForkJoinTask computations (as may be determined using method
1012 <     * {@link #inForkJoinPool}). Attempts to invoke in other contexts
1013 <     * result in exceptions or errors, possibly including
1014 <     * ClassCastException.  *
1010 >     * exceeded.
1011 >     *
1012 >     * <p>This method may be invoked only from within {@code
1013 >     * ForkJoinTask} computations (as may be determined using method
1014 >     * {@link #inForkJoinPool}).  Attempts to invoke in other contexts
1015 >     * result in exceptions or errors, possibly including {@code
1016 >     * ClassCastException}.
1017 >     *
1018       * @return the surplus number of tasks, which may be negative
1019       */
1020      public static int getSurplusQueuedTaskCount() {
# Line 1001 | Line 1050 | public abstract class ForkJoinTask<V> im
1050       * called otherwise. The return value controls whether this task
1051       * is considered to be done normally. It may return false in
1052       * asynchronous actions that require explicit invocations of
1053 <     * {@link #complete} to become joinable. It may throw exceptions
1054 <     * to indicate abnormal exit.
1053 >     * {@link #complete} to become joinable. It may also throw an
1054 >     * (unchecked) exception to indicate abnormal exit.
1055       *
1056       * @return {@code true} if completed normally
1008     * @throws Error or RuntimeException if encountered during computation
1057       */
1058      protected abstract boolean exec();
1059  
# Line 1017 | Line 1065 | public abstract class ForkJoinTask<V> im
1065       * null even if a task exists but cannot be accessed without
1066       * contention with other threads.  This method is designed
1067       * primarily to support extensions, and is unlikely to be useful
1068 <     * otherwise.  This method may be invoked only from within
1069 <     * ForkJoinTask computations (as may be determined using method
1070 <     * {@link #inForkJoinPool}). Attempts to invoke in other contexts
1071 <     * result in exceptions or errors, possibly including
1072 <     * ClassCastException.
1068 >     * otherwise.
1069 >     *
1070 >     * <p>This method may be invoked only from within {@code
1071 >     * ForkJoinTask} computations (as may be determined using method
1072 >     * {@link #inForkJoinPool}).  Attempts to invoke in other contexts
1073 >     * result in exceptions or errors, possibly including {@code
1074 >     * ClassCastException}.
1075       *
1076       * @return the next task, or {@code null} if none are available
1077       */
# Line 1034 | Line 1084 | public abstract class ForkJoinTask<V> im
1084       * Unschedules and returns, without executing, the next task
1085       * queued by the current thread but not yet executed.  This method
1086       * is designed primarily to support extensions, and is unlikely to
1087 <     * be useful otherwise.  This method may be invoked only from
1088 <     * within ForkJoinTask computations (as may be determined using
1089 <     * method {@link #inForkJoinPool}). Attempts to invoke in other
1090 <     * contexts result in exceptions or errors, possibly including
1091 <     * ClassCastException.
1087 >     * be useful otherwise.
1088 >     *
1089 >     * <p>This method may be invoked only from within {@code
1090 >     * ForkJoinTask} computations (as may be determined using method
1091 >     * {@link #inForkJoinPool}).  Attempts to invoke in other contexts
1092 >     * result in exceptions or errors, possibly including {@code
1093 >     * ClassCastException}.
1094       *
1095       * @return the next task, or {@code null} if none are available
1096       */
# Line 1055 | Line 1107 | public abstract class ForkJoinTask<V> im
1107       * {@code null} result does not necessarily imply quiescence
1108       * of the pool this task is operating in.  This method is designed
1109       * primarily to support extensions, and is unlikely to be useful
1110 <     * otherwise.  This method may be invoked only from within
1111 <     * ForkJoinTask computations (as may be determined using method
1112 <     * {@link #inForkJoinPool}). Attempts to invoke in other contexts
1113 <     * result in exceptions or errors, possibly including
1114 <     * ClassCastException.
1110 >     * otherwise.
1111 >     *
1112 >     * <p>This method may be invoked only from within {@code
1113 >     * ForkJoinTask} computations (as may be determined using method
1114 >     * {@link #inForkJoinPool}).  Attempts to invoke in other contexts
1115 >     * result in exceptions or errors, possibly including {@code
1116 >     * ClassCastException}.
1117       *
1118       * @return a task, or {@code null} if none are available
1119       */
# Line 1124 | Line 1178 | public abstract class ForkJoinTask<V> im
1178      }
1179  
1180      /**
1181 <     * Returns a new ForkJoinTask that performs the {@code run}
1182 <     * method of the given Runnable as its action, and returns a null
1183 <     * result upon {@code join}.
1181 >     * Returns a new {@code ForkJoinTask} that performs the {@code run}
1182 >     * method of the given {@code Runnable} as its action, and returns
1183 >     * a null result upon {@link #join}.
1184       *
1185       * @param runnable the runnable action
1186       * @return the task
# Line 1136 | Line 1190 | public abstract class ForkJoinTask<V> im
1190      }
1191  
1192      /**
1193 <     * Returns a new ForkJoinTask that performs the {@code run}
1194 <     * method of the given Runnable as its action, and returns the
1195 <     * given result upon {@code join}.
1193 >     * Returns a new {@code ForkJoinTask} that performs the {@code run}
1194 >     * method of the given {@code Runnable} as its action, and returns
1195 >     * the given result upon {@link #join}.
1196       *
1197       * @param runnable the runnable action
1198       * @param result the result upon completion
# Line 1149 | Line 1203 | public abstract class ForkJoinTask<V> im
1203      }
1204  
1205      /**
1206 <     * Returns a new ForkJoinTask that performs the {@code call}
1207 <     * method of the given Callable as its action, and returns its
1208 <     * result upon {@code join}, translating any checked
1209 <     * exceptions encountered into {@code RuntimeException}.
1206 >     * Returns a new {@code ForkJoinTask} that performs the {@code call}
1207 >     * method of the given {@code Callable} as its action, and returns
1208 >     * its result upon {@link #join}, translating any checked exceptions
1209 >     * encountered into {@code RuntimeException}.
1210       *
1211       * @param callable the callable action
1212       * @return the task

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines