Skip to content

Fix compatibility with parallel stream (master) #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

szpak
Copy link
Contributor

@szpak szpak commented Mar 16, 2016

identity value provided in reduce is reused across threads and the accumulation operation needs to work on a copy. For more memory efficient reduce operation a dedicated Collector with mutable internal accumulator can be used.

Also added tests to verify that custom user implementation is parallel stream compatible and a logger to show in practice how values change in each step.

@szpak szpak changed the title Fix compatibility with parallel stream Fix compatibility with parallel stream (master) Mar 16, 2016
@nurkiewicz
Copy link
Owner

As a second thought (also to #5), do we really want to even talk about parallel streams here? They are mentioned briefly several lessons later, only to tell they are a bad idea. I'm reluctant to test them here. Also the test code is much more complex then before, which makes learning curve steeper.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants