title: Update thread variable (c++)
body: <p>The actual problem is, that i try to send a new parameter to a running thread.
  The idea was to change a variable in the thread, which did not work.
  The code should display an easy example of the problem.
  The printed variable test should be 1 after updating, but it is always 0.
  Does anybody understand the problem and can help?
  Thanks a lot!</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;thread&gt;
  
  class MyThread {
  public:
  int test = 0;
  void operator()() const {
      while (1)
      std::cout &lt;&lt; test &lt;&lt; std::endl;
  }
  /* other public or private class members */
  };
  
  int main() {
      MyThread mythread;
      std::thread t(mythread);
      mythread.test = 1;
      t.join();
      return 0;
  }
  </code></pre>