Accessing different data members belonging to the same object from 2 different thread in C++
- 阅读更多 关于 Accessing different data members belonging to the same object from 2 different thread in C++
问题 I have a few objects I need to perform actions on from different threads in c++. I known it is necessary to lock any variable that may be used by more than one thread at the same time, but what if each thread is accessing (writing to) a different data member of the same object? For example, each thread is calling a different method of the object and none of the methods called modify the same data member. Is it safe as long as I don't access the same data member or do I need to lock the whole