title: Thread Communication when Debug mode and Release Mode
body: <p>Threads does not communicate each other while release mode but they do communicate while debug mode. Also Threads do communicate if i make thread sleep for 0.1 second while release mode. Why it is happening ? There are example for you.</p>
  
  <p>main.cpp </p>
  
  <pre><code>int main(){
  bool foo=false;
  
  
  thread tk(control,ref(foo));
  tk.detach();
  this_thread::sleep_for(1s);
  foo=true;
  while(true){
  //it is for program is not finished
  
  }
  }
  
  </code></pre>
  
  <p>foo.cpp</p>
  
  <pre><code>void control(bool &amp;x){
  while(x==false){
     //When release mode, program cannot go out from this.
  }
  
  }
  
  </code></pre>
  
  <p>And There are working example for you </p>
  
  <p>main.cpp </p>
  
  <pre><code>int main(){
  bool foo=false;
  
  
  thread tk(control,ref(foo));
  tk.detach();
  this_thread::sleep_for(1s);
  foo=true;
  while(true){
  //it is for program is not finished
  
  }
  }
  </code></pre>
  
  <p>foo.cpp</p>
  
  <pre><code>void control(bool &amp;x){
  while(x==false){
    this_thread::sleep_for(1s);
  //it can go out.
  }
  
  }
  
  </code></pre>