title: Member variable doesn't get changed in another thread?
body: <p>I've asked a question a few minutes ago and now I've got a new problem.
  I've got a code like this:</p>
  
  <pre><code>class foo{
  public:
  
      void loop(){
          this-&gt;running = true;
  
          while(this-&gt;running){
              // do stuff
          }
      }
  
      void exitLoop(){
          this-&gt;running = false;
      }
  
  private:
  
      bool running;
  };
  
  int main(){
      foo theFoo = foo(); 
  
      thread fooLoop(&amp;foo::loop, theFoo);
  
      // do stuff
  
      theFoo.exitLoop();
  
      fooLoop.join();
  }
  </code></pre>
  
  <p>When I'm calling <code>theFoo.exitLoop()</code>, <code>running</code> should be set to <code>false</code> and the loop/thread should exit. But when I'm calling <code>exitLoop()</code>, the while-loop just continues. When I'm checking the value of <code>running</code> inside the loop, I'm getting <code>true</code>, but it should be <code>false</code>, so that the loop exits. </p>
  
  <p>When I'm not using a member variable but a global one, everything works fine. 
  What am I doing wrong? </p>