title: how to terminate a sleeping thread in pthread?
body: <p>I have thread which sleeps for a long time, then wakes up to do something, then sleep again, like this:</p>
  
  <pre><code>while(some_condition)
  {
      // do something
      sleep(1000);
  }
  </code></pre>
  
  <p>How could I make this thread exit gracefully and QUICKLY?</p>
  
  <p>I tried to use <code>pthread_cancel()</code>, but sleeping threads could not be canceled.
  I also tried changing the condition of the while loop, but it will still take long to exit.
  And I don't want to use <code>pthread_kill()</code>, since it may kill the thread when it's working.</p>
  
  <p>So, are there any good ideas?</p>