title: How to pause/resume thread in Android?
body: <p>I have a thread that running into an activity. I <strong>don't want</strong> that the thread continuos running when the user click the home button or, for example, the user receive a call phone.
  So I want pause the thread and resume it when the user re-opens the application.
  I've tried with this:</p>
  
  <pre><code>protected void onPause() {
    synchronized (thread) {
      try {
        thread.wait();
      } catch (InterruptedException e) {
        e.printStackTrace();
      }
    }
    super.onPause();
  }
  protected void onResume() {
    thread.notify();
    super.onResume();
  }
  </code></pre>
  
  <p>It stops the thread but don't resume it, the thread seems freezed.</p>
  
  <p>I've also tried with the deprecated method <code>Thread.suspend()</code> and <code>Thread.resume()</code>, but in this case into <code>Activity.onPause()</code> the thread doesn't stop.</p>
  
  <p>Anyone know the solution?</p>