8000 java-8/src/com/learnJava8/streamsparallel at master · dmiller2117/java-8 · GitHub
[go: up one dir, main page]

Skip to content

Latest commit

 

History

History

README.md

Stream Parallel Operations

What is a Parallel Stream?

  • Splits the source of the data into multiple parts
  • Process them parallelly.
  • Combine the result.

How to Create a Parallel Stream?

Sequential Stream:

IntStream.rangeClosed(1, 1000) .sum()

Parallel Stream:

IntStream.rangeClosed(1, 1000) .parallel() .sum()

How Parallel Stream works?

  • Parallel Streams use the Fork/Join framework that got introduced in Java 7

How many Threads are created?

  • Number of threads created == number of processors available in the machine
0