title: windows c++ multi thread
body: <p>I am having some trouble with multi threaded c++ code on windows.    </p>
  
  <pre><code>class test
  {
  public:
      bool flag;
      test() {flag=true;}
      void start_do(){while(flag) puts("doing...");}
      void stop_do() {flag=0;}
  }
  
  int main()
  {
      test t;
      HANDLE h=CreateThread(0,0,(LPTHREAD_START_ROUTINE)t.start_do,0,1,0);
      Sleep(5000);
      t.stop_do();
      return 0;
  }
  </code></pre>
  
  <p>I want to change the doing state with the flag. But it doesn't work.
  Could someone give me some help!</p>