LongStream parallel() is a method in java.util.stream.LongStream. This method returns a parallel LongStream, i.e, it may return itself, either because the stream was already present, or because the underlying stream state was modified to be parallel.
LongStream parallel() is an intermediate operation. These operations are always lazy. Intermediate operations are invoked on a Stream instance and after they finish their processing, they give a Stream instance as output.
LongStream parallel() Where, LongStream is a sequence of primitive long-valued elements and the function returns a parallel LongStream.
Below given are some examples to understand the function in a better way.
Example 1 :
The corresponding parallel LongStream is : 9 8 11 10 6 5 7
Example 2 :
The corresponding sequential LongStream is : 5 6 7 8 9 10 11
Example 3 :
The sorted parallel LongStream is : 4 2 3 9 3 5 1
Attention reader! Don’t stop learning now. Get hold of all the important Java and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready.
- LongStream.Builder build() in Java
- java.util.stream.IntStream/LongStream | Search an element
- LongStream sum() in Java
- LongStream generate() method in Java
- LongStream peek() in Java with examples
- LongStream rangeClosed() in Java
- LongStream range() in Java
- LongStream sequential() in Java
- LongStream skip() in Java
- LongStream sorted() in Java
- LongStream summaryStatistics() in Java
- LongStream average() in Java with Examples
- LongStream concat() in Java
- LongStream count() in Java with examples
- LongStream distinct() in Java with examples
- LongStream allMatch() in Java with examples
- LongStream anyMatch() in Java with examples
- LongStream of() in Java
- LongStream findFirst() in Java
- LongStream empty() in Java with examples
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.