Parallel Stream
This lesson introduces parallel streams, which are used to process the stream elements in parallel.
Until now, we have only been looking at serial Stream. However, Java 8 introduced the concepts of the parallel stream and parallel processing. As we have a greater number of CPU cores nowadays, due to cheap hardware costs, parallel processing can be used to perform operation faster.
Creating a parallel stream
There are two ways in which we can create a parallel Stream:
- Using the
parallelStream()
method. - Or, if we already have a stream, we can use the
parallel()
method to