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
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