Java 8 Parallel Streams Internals (Part 1) - Vanderbilt University

Java 8 Parallel Streams Internals

(Part 1)

Douglas C. Schmidt

d.schmidt@vanderbilt.edu dre.vanderbilt.edu/~schmidt

Professor of Computer Science Institute for Software Integrated Systems Vanderbilt University

Nashville, Tennessee, USA

Learning Objectives in this Part of the Lesson

? Understand parallel stream internals

List

List1

trySplit()

List2

trySplit()

trySplit()

List1.1

List1.2 List2.1

List2.2

Process sequentially

Process sequentially

Process sequentially

Process sequentially

join

join

join

See developerworks2/library/j-java-streams-3-brian-goetz

Learning Objectives in this Part of the Lesson

? Understand parallel stream internals, e.g. ? Know what can change & what can't

See en.3/wiki/Serenity_Prayer

Why Knowledge of Parallel Streams Matters

4

Why Knowledge of Parallel Streams Matters

? Converting a Java 8 sequential stream to a parallel stream is usually quite straightforward

Changing stream() calls to parallelStream() calls

involves minuscule effort!!

List processStream() {

return getInput() .stream() .map(this::processInput) .collect(toList());

}

vs

List processStream() {

return getInput() .parallelStream() .map(this::processInput) .collect(toList());

}

See "Java 8 SearchWith5ParallelStreams Example"

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download