Skip to content
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

Item 38 use lock to prevent data races in threads #34

Open
OpetherMB opened this issue Apr 15, 2024 · 0 comments
Open

Item 38 use lock to prevent data races in threads #34

OpetherMB opened this issue Apr 15, 2024 · 0 comments

Comments

@OpetherMB
Copy link

i guess we should clear to the readers that += in you specific example it is an atomic operation and if you run the code multiple times you will always the right answer Counter should be 500000, found 500000, because in 3.X version of python they were consistently made to be atomic and so i guess the code is misleading especially for new readers ! i can suggest other senarios where we will have data races if you will

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

No branches or pull requests

1 participant