Sorry, I meant how to guard against race conditions where multiple threads try to write to the same shared memory?
This is clasically done via memory synchronization mechanisms/atomics.
This is clasically done via memory synchronization mechanisms/atomics.
You do need to synchronize concurrent access to the same object, and it's not just concurrent writes, it's concurrent accesses if at least one of them is a write.