Java Reference
In-Depth Information
the stream are combined when the subparts are processed in parallel. In the toList case, the
implementation of this method is simple; just add the list containing the items gathered from
the second subpart of the stream to the end of the list obtained when traversing the first
subpart:
public BinaryOperator<List<T>> combiner() {
return (list1, list2) -> {
list1.addAll(list2);
return list1; }
}
The addition of this fourth method allows a parallel reduction of the stream. This uses the
fork/join framework introduced in Java 7 and the Spliterator abstraction that you'll learn about
in the next chapter. It follows a process similar to the one shown in figure 6.8 and described in
detail here:
 
Search WWH ::




Custom Search