Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8132800

clarify stream package documentation regarding sequential vs parallel modes

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 9
    • Component/s: core-libs
    • Labels:

      Backports

        Description

        The "Parallelism" section of the java.util.stream package-info.java file has the following:

         * <p>The only difference between the serial and parallel versions of this
         * example is the creation of the initial stream, using "{@code parallelStream()}"
         * instead of "{@code stream()}". When the terminal operation is initiated,
         * the stream pipeline is executed sequentially or in parallel depending on the
         * orientation of the stream on which it is invoked. Whether a stream will execute in serial or
         * parallel can be determined with the {@code isParallel()} method, and the
         * orientation of a stream can be modified with the
         * {@link java.util.stream.BaseStream#sequential()} and
         * {@link java.util.stream.BaseStream#parallel()} operations. When the terminal
         * operation is initiated, the stream pipeline is executed sequentially or in
         * parallel depending on the mode of the stream on which it is invoked.

        It needs to be clarified that the sequential or parallel mode applies to the entire stream pipeline, not just the latest stream object, or something. (This is a repeated question from people learning the Streams API.)

        Also, the second and the last sentences are redundant.
         

          Attachments

            Issue Links

              Activity

                People

                Assignee:
                smarks Stuart Marks
                Reporter:
                smarks Stuart Marks
                Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                  Dates

                  Created:
                  Updated:
                  Resolved: