title: Why an empty while loop don't react the same as a while loop with something in it?
body: <p>I have currently 2 pthreads running and I would like to wait for one of them to end for my program to continue.</p>
  
  <p>In my pthreads I have a variable which can be true or false (it is a global variable). After creating the thread (one asking for a input in a cin and one waiting 10 seconds and if it reach 10 sec it kill the "cin" thread and end itself, the "cin" thread kill the "timer" thread if there is cin detected) I would like for my program to wait. When each of the thread end they put a variable "stoptimer" to true.</p>
  
  <p>First after creating the threads I started writing a while loop like this :</p>
  
  <pre><code>while(stoptimer==false){}
  </code></pre>
  
  <p>The threads start, we enter into the while loop but even when the threads end and "stoptimer" goes to true we don't exit the loop.</p>
  
  <p>I am currently doing this :</p>
  
  <pre><code>rc = pthread_create(&amp;threads[1], NULL, Timer, (void *)&amp;td[1]);
  if (rc) {
      cout &lt;&lt; "Error:unable to create thread," &lt;&lt; rc &lt;&lt; endl;
      exit(-1);
  }
  
  rc = pthread_create(&amp;threads[2], NULL, Choix, (void *)&amp;i);
  if (rc) {
      cout &lt;&lt; "Error:unable to create thread," &lt;&lt; rc &lt;&lt; endl;
      exit(-1);
  }
  
  while (stoptimer==false) {
      cout&lt;&lt;"wait"&lt;&lt;endl;
  }
  </code></pre>
  
  <p>Here you can see I am creating the threads and then entering the while loop with something in it. If I keep this loop as it is it is doing what I want, when the timer end or the user input a value we quit the while because "stoptimer" is no more false. But I don't want this cout to be here. </p>
  
  <p>I tried putting a comment inside the loop in order for it to not be empty but it still react as being empty. In my understanding if it worked with the count then now it should work but simply do nothing.</p>
  
  <p>Why is it doing this?  Is there something special about empty while loop?</p>