From the course: Functional Programming with Java

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Parallel streams

Parallel streams - Java Tutorial

From the course: Functional Programming with Java

Start my 1-month free trial

Parallel streams

- [Instructor] So we've come quite a long way in our understanding of stream since the beginning of the section, and before we move on, there's one more little thing that we're going to look at regarding streams. You see, in all the examples that we've been using so far with functions like map, filter, and so on, the streams that we've been using have been serial streams, and what this means is that all the elements in our stream are processed one after the other in order. We saw proof of this earlier when we put a system.out.println statement inside the function we pass to reduce. When we run this program, we see that all the elements from our original list are processed one by one in the order that they were found in. Now the interesting thing, though, is that there's an alternative to this. Instead of using serial streams to process our list elements, we can use something called parallel streams. Now before we get into exactly what parallel streams are and how they work, let's see…

Contents