530 * <p>If a source cannot directly supply a recommended spliterator then it may indirectly supply a spliterator
531 * using a {@code Supplier}. The spliterator is obtained from the supplier after, and never before, the terminal
532 * operation of the stream pipeline commences.
533 *
534 * <p>Such requirements significantly reduce the scope of potential interference to the interval starting
535 * with the commencing of the terminal operation and ending with the producing a result or side-effect. See
536 * <a href="package-summary.html#Non-Interference">Non-Interference</a> for
537 * more details.
538 *
539 * XXX - move the following to the non-interference section
540 *
541 * <p>A source can be modified before the terminal operation commences and those modifications will be reflected in
542 * the covered elements. Afterwards, and depending on the properties of the source, further modifications
543 * might not be reflected and the throwing of a {@code ConcurrentModificationException} may occur.
544 *
545 * <p>For example, consider the following code:
546 * <pre>{@code
547 * List<String> l = new ArrayList(Arrays.asList("one", "two"));
548 * Stream<String> sl = l.stream();
549 * l.add("three");
550 * String s = sl.collect(toStringJoiner(" ")).toString();
551 * }</pre>
552 * First a list is created consisting of two strings: "one"; and "two". Then a stream is created from that list.
553 * Next the list is modified by adding a third string: "three". Finally the elements of the stream are collected
554 * and joined together. Since the list was modified before the terminal {@code collect} operation commenced
555 * the result will be a string of "one two three". However, if the list is modified after the terminal operation
556 * commences, as in:
557 * <pre>{@code
558 * List<String> l = new ArrayList(Arrays.asList("one", "two"));
559 * Stream<String> sl = l.stream();
560 * String s = sl.peek(s -> l.add("BAD LAMBDA")).collect(toStringJoiner(" ")).toString();
561 * }</pre>
562 * then a {@code ConcurrentModificationException} will be thrown since the {@code peek} operation will attempt
563 * to add the string "BAD LAMBDA" to the list after the terminal operation has commenced.
564 */
565
566 package java.util.stream;
|
530 * <p>If a source cannot directly supply a recommended spliterator then it may indirectly supply a spliterator
531 * using a {@code Supplier}. The spliterator is obtained from the supplier after, and never before, the terminal
532 * operation of the stream pipeline commences.
533 *
534 * <p>Such requirements significantly reduce the scope of potential interference to the interval starting
535 * with the commencing of the terminal operation and ending with the producing a result or side-effect. See
536 * <a href="package-summary.html#Non-Interference">Non-Interference</a> for
537 * more details.
538 *
539 * XXX - move the following to the non-interference section
540 *
541 * <p>A source can be modified before the terminal operation commences and those modifications will be reflected in
542 * the covered elements. Afterwards, and depending on the properties of the source, further modifications
543 * might not be reflected and the throwing of a {@code ConcurrentModificationException} may occur.
544 *
545 * <p>For example, consider the following code:
546 * <pre>{@code
547 * List<String> l = new ArrayList(Arrays.asList("one", "two"));
548 * Stream<String> sl = l.stream();
549 * l.add("three");
550 * String s = sl.collect(joining(" "));
551 * }</pre>
552 * First a list is created consisting of two strings: "one"; and "two". Then a stream is created from that list.
553 * Next the list is modified by adding a third string: "three". Finally the elements of the stream are collected
554 * and joined together. Since the list was modified before the terminal {@code collect} operation commenced
555 * the result will be a string of "one two three". However, if the list is modified after the terminal operation
556 * commences, as in:
557 * <pre>{@code
558 * List<String> l = new ArrayList(Arrays.asList("one", "two"));
559 * Stream<String> sl = l.stream();
560 * String s = sl.peek(s -> l.add("BAD LAMBDA")).collect(joining(" "));
561 * }</pre>
562 * then a {@code ConcurrentModificationException} will be thrown since the {@code peek} operation will attempt
563 * to add the string "BAD LAMBDA" to the list after the terminal operation has commenced.
564 */
565
566 package java.util.stream;
|