Common Java Streams Mistakes (part 4): Sharing Unsynchronized Mutable State in Java Parallel Streams

preview_player
Показать описание
This video analyzes implementations of various ways of computing factorials for BigIntegers to demonstrate the performance of alternative parallel and sequential algorithms, as well as the dangers of sharing unsynchronized state between threads.
Рекомендации по теме
Комментарии
Автор

If there was a MutableBigInteger, it might be faster to use mutable reduction (aka collect()) as it would save on creating a BigInteger for every intermediate result..

timwalters
Автор

Does the get() method on the synchronised solution need to be synchronised? Seems like the get method is only being called after the stream processing has been completed.

timwalters
welcome to shbcf.ru