I have a fairly simple question, however the answer seems to elude me. If I have multiple objects of the same c++ class, each object in it’s own thread, do I need to be aware of concurrent access issues? Or are things automatically thread-safe for separate instances? Of course I would expect issues with static methods, but instance methods?
Share
It depends. Frequently one instance of a class will be independent of operations on other instances. If this is the case in a single thread, it is also true with multiple threads.
For example, consider a value-type class representing a Point.
An instance of this class in one thread will be unaffected by operations on a different instance in another thread.
However, an instance of a class can interact with other objects. If two instances can interact with the same object, then yes, you do need to be concerned about thread-safety.