Sequential Stream VS Parallel Stream in Java 8(Performance testing)

preview_player
Показать описание
In this video, we are doing a performance testing between a Sequential Stream and a Parallel Stream. We have written and explained the code line by line and executed the code to show the actual performance time. Please watch and provide your valuable comments
Рекомендации по теме
Комментарии
Автор

This is not a good example for parallel streams. Since ArrayList#add is not thread safe, the results of adding these number are undefined. If you look at the implementation of ArrayList#add, it increments the internal size field, without any synchronization or volatile semantics. You also did not check if the results of using parallel or sequential methods yield similar results.

ralf