Thinking In Parallel by Stuart Marks and Brian Goetz

Devoxx · 16K views · 2016 · 1:00:04

Open on YouTube

Functional programmingSoftware performance & optimizationC, C++, Rust, Go & systems languagestalk

Why Stack Overflow recommends it

Stack Overflow users link it when explaining when parallel streams help, why mutating shared state in them is wrong, and why fork/join does not always speed things up.

Recommended by 3 people across 2 different months, 2015 to 2019.

What it is

A Devoxx conference talk by Oracle's Stuart Marks and Brian Goetz on writing Java 8 stream code that runs correctly in parallel. It argues against imperative, mutation-heavy thinking and introduces array-style programming, where operations apply to whole data aggregates, with examples and demos.

What people said

Strong rec mwdev · 2019-10 · Stack Overflow · on “Java parallel stream use or not to use”

Here is very interesting talk which shares some wisdom around the question "when to consider using parallel streams?", shared by Brian Goetz himself. He takes over in the second part of this seminar: [this video] Brian Goetz is the Java Language Architect at Oracle, and was the specification lead for JSR-335 (Lambda Expressions for the Java Programming Language.) He is the author of the best-selling Java Concurrency in Practice, as well as over 75 articles on Java development, and has been fascinated by programming since Jimmy Carter was President.

Recommends Manoel Campos · 2017-02 · Stack Overflow · on “Why not modify a Set within a parallelStream?”

Parallel streams are supposed not to mutate variables state. Doing that may result in ConcurrentModificationException [LINK] . Check the link to understand why. If you really need to do that, your design is probably wrong. If you need to synchronize, you are increasing additional wait time since your threads will not run independently, reducing eventual performance gains that the parallelization might provide for your problem. Check this explanatory video [this video] .

Recommends Pavel Rozenblioum · 2017-02 · Stack Overflow · on “Fork join not giving better performance”

There are very many cases where you shouldn't expect better performance when using fork join since overhead of forking and joining might get quite big. See, for example this talk (mostly second half) [this video]

Cites Stuart Marks · 2015-03 · Stack Overflow · on “Splitting List into sublists along elements”

Although there are several answers already, and an accepted answer, there are still a couple points missing from this topic. First, the consensus seems to be that solving this problem using streams is merely an exercise, and that the conventional for-loop approach is preferable. Second, the answers given thus far have overlooked an approach using array or vector-style techniques that I think improves the streams solution considerably. First, here's a conventional solution, for purposes of discussion and analysis: static List<List<String>> splitConventional(List<String> input) { List<List<String>> result = new ArrayList<>(); int prev = 0; for (int cur = 0; cur < input.size(); cur++) { if (inp

Cites user1803551 · 2016-11 · Stack Overflow · on “Splitting List into sublists along elements”

For those who are interested in more insight: a lecture by the answerer talking about this question [this video] .