I have a class method in which I want to read the same non-atomic class member simultaneously in different threads. The method is const
, so it doesn't write to the member being read. Is it safe to not bother about any locks in this case?
Edit: I should have given an example:
class SomeClass()
{
public:
void someMethod() const;
//...
private:
std::string someMemeber_; // might be changed by some methods
//...
}
void SomeClass::someMethod() const
{
std::jthread thr1([](){/*read someMember_ here*/});
std::jthread thr2([](){/*read someMember_ here*/});
//...
}