The Power and Perils of Parallel Streams

preview_player
Показать описание
Venkat Subramaniam, President, Agile Developer, Inc.

“If streams can be parallel, why not make them parallel all the time?” is a common question from developers being introduced to Java 8 streams. This session tackles three separate topics:
1. When to consider parallelization and when not to
2. How to parallelize, how to decide on the number of threads, and how to control the threads pool
3. Some common mistakes people make when using parallel streams

The goal of the session is to explain when and how to make good use of parallel streams.
Рекомендации по теме
Комментарии
Автор

Venkat and Josh Long are such great presenters, better than any professor I've had.

Dobby_zuul
Автор

Summary - 35:26 +
Before you turn your code into parallel:
1. Do you have a lot of data to process?
2. Do you have a lot of work to do?
Always do project specific benchmarking personally.
With findFirst, sequential streams are lazy and stop processing once the result is found, whereas parallel streams compute on partitions of data until the result is found in each individual partition, independent of the other partitions' result, then join their results, which makes parallel processing more computationally intensive.

ErsinErtan
Автор

Best talk ever on parallel streams!!!!

SuperMogan
Автор

at 30:00 around.. when you changed the forkjoinpool settings at the jvm level to have 100 threads by default at the same time and then ran the program.. how are they able to run parallely when your mahine happened to have the 4 cores as you said, and at max 8 cores as per information given by your java runtime environment (m assuming that it could be due to 4 physical cores + 4 logical cores, as is the case with that proprietary hyper threading model of intel cpu architecture) .. program should still at best have run 7 threads at a time despite creating 100 threads .. rest of the threads should have waited to get their turn .. so it still should have run in 3 busts no? or am i missing something?

Автор

At 33:06 we are performing then compute method parallely, we are introducing shared mutability do we need to have kind of synchronization here ?

gyan
Автор

Can anyone recommend a good
book to understand java memory model ?

maobesoya