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.27 by dl, Sun Aug 2 11:54:31 2009 UTC vs.
Revision 1.28 by jsr166, Sun Aug 2 17:02:06 2009 UTC

# Line 22 | Line 22 | import java.util.WeakHashMap;
22   * subtasks may be hosted by a small number of actual threads in a
23   * ForkJoinPool, at the price of some usage limitations.
24   *
25 < * <p> A "main" ForkJoinTask begins execution when submitted to a
26 < * {@link ForkJoinPool}. Once started, it will usually in turn start
27 < * other subtasks.  As indicated by the name of this class, many
28 < * programs using ForkJoinTasks employ only methods {@code fork} and
29 < * {@code join}, or derivatives such as {@code invokeAll}.  However,
30 < * this class also provides a number of other methods that can come
31 < * into play in advanced usages, as well as extension mechanics that
32 < * allow support of new forms of fork/join processing.
25 > * <p>A "main" {@code ForkJoinTask} begins execution when submitted
26 > * to a {@link ForkJoinPool}.  Once started, it will usually in turn
27 > * start other subtasks.  As indicated by the name of this class,
28 > * many programs using {@code ForkJoinTask} employ only methods
29 > * {@link #fork} and {@link #join}, or derivatives such as {@link
30 > * #invokeAll}.  However, this class also provides a number of other
31 > * methods that can come into play in advanced usages, as well as
32 > * extension mechanics that allow support of new forms of fork/join
33 > * processing.
34   *
35 < * <p>A ForkJoinTask is a lightweight form of {@link Future}.  The
36 < * efficiency of ForkJoinTasks stems from a set of restrictions (that
37 < * are only partially statically enforceable) reflecting their
38 < * intended use as computational tasks calculating pure functions or
39 < * operating on purely isolated objects.  The primary coordination
40 < * mechanisms are {@link #fork}, that arranges asynchronous execution,
41 < * and {@link #join}, that doesn't proceed until the task's result has
42 < * been computed.  Computations should avoid {@code synchronized}
43 < * methods or blocks, and should minimize other blocking
44 < * synchronization apart from joining other tasks or using
45 < * synchronizers such as Phasers that are advertised to cooperate with
46 < * fork/join scheduling. Tasks should also not perform blocking IO,
47 < * and should ideally access variables that are completely independent
48 < * of those accessed by other running tasks. Minor breaches of these
49 < * restrictions, for example using shared output streams, may be
50 < * tolerable in practice, but frequent use may result in poor
51 < * performance, and the potential to indefinitely stall if the number
52 < * of threads not waiting for IO or other external synchronization
53 < * becomes exhausted. This usage restriction is in part enforced by
54 < * not permitting checked exceptions such as {@code IOExceptions}
55 < * to be thrown. However, computations may still encounter unchecked
56 < * exceptions, that are rethrown to callers attempting join
57 < * them. These exceptions may additionally include
58 < * RejectedExecutionExceptions stemming from internal resource
59 < * exhaustion such as failure to allocate internal task queues.
35 > * <p>A {@code ForkJoinTask} is a lightweight form of {@link Future}.
36 > * The efficiency of {@code ForkJoinTask}s stems from a set of
37 > * restrictions (that are only partially statically enforceable)
38 > * reflecting their intended use as computational tasks calculating
39 > * pure functions or operating on purely isolated objects.  The
40 > * primary coordination mechanisms are {@link #fork}, that arranges
41 > * asynchronous execution, and {@link #join}, that doesn't proceed
42 > * until the task's result has been computed.  Computations should
43 > * avoid {@code synchronized} methods or blocks, and should minimize
44 > * other blocking synchronization apart from joining other tasks or
45 > * using synchronizers such as Phasers that are advertised to
46 > * cooperate with fork/join scheduling. Tasks should also not perform
47 > * blocking IO, and should ideally access variables that are
48 > * completely independent of those accessed by other running
49 > * tasks. Minor breaches of these restrictions, for example using
50 > * shared output streams, may be tolerable in practice, but frequent
51 > * use may result in poor performance, and the potential to
52 > * indefinitely stall if the number of threads not waiting for IO or
53 > * other external synchronization becomes exhausted. This usage
54 > * restriction is in part enforced by not permitting checked
55 > * exceptions such as {@code IOExceptions} to be thrown. However,
56 > * computations may still encounter unchecked exceptions, that are
57 > * rethrown to callers attempting join them. These exceptions may
58 > * additionally include RejectedExecutionExceptions stemming from
59 > * internal resource exhaustion such as failure to allocate internal
60 > * task queues.
61   *
62   * <p>The primary method for awaiting completion and extracting
63   * results of a task is {@link #join}, but there are several variants:
# Line 74 | Line 76 | import java.util.WeakHashMap;
76   * performs the most common form of parallel invocation: forking a set
77   * of tasks and joining them all.
78   *
79 < * <p> The ForkJoinTask class is not usually directly subclassed.
79 > * <p>The ForkJoinTask class is not usually directly subclassed.
80   * Instead, you subclass one of the abstract classes that support a
81   * particular style of fork/join processing, typically {@link
82   * RecursiveAction} for computations that do not return results, or
# Line 698 | Line 700 | public abstract class ForkJoinTask<V> im
700       * still ensure that these minimal properties hold. In particular,
701       * the cancel method itself must not throw exceptions.
702       *
703 <     * <p> This method is designed to be invoked by <em>other</em>
703 >     * <p>This method is designed to be invoked by <em>other</em>
704       * tasks. To terminate the current task, you can just return or
705       * throw an unchecked exception from its computation method, or
706       * invoke {@link #completeExceptionally}.

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines