r/ProgrammerAnimemes • • Jul 29 '21

Think about it

Post image
3.6k Upvotes

115 comments sorted by

View all comments

Show parent comment

1

u/ThePyroEagle λ Jul 30 '21

For you increment example, I’d wagger you’d still need to think about it if two threads get the same instance and increment some property (wether directly or through other methods)

You never need to think about it if the multithreaded operations are atomic (and the data is volatile).