What is the scope and lifetime of myobj ?
If you're doing this
Code:
MyClass *obj = new MyClass;
std::thread t(&MyClass::MyMethod, myobj);
and MyMethod has the ability to do say
delete this; as final act of suicide, then calling
this->SetRunning(false) in any other thread is exceedingly risky.
But if myobj always outlives the thread instance of MyMethod, then calling SetRunning only really has to worry about concurrent access to whatever instance variable is being updated inside the object.
Atomic operations library - cppreference.com