title: How to stop a thread running a blocking method
body: <p>I'm making a server application and I'm using a thread running in a while(true) a blocking listening function.</p>
  
  <p>How can I stop the thread?
  I can't use this kind of code:</p>
  
  <pre><code>while(true)
  {
      BlockingMethod();
      if(shouldStop)
          return;
  }
  </code></pre>
  
  <p>Because it will be executed till BlockingMethod "unblocks"...</p>