title: Android : game loop pause/resume issue
body: <p>I am able to pause/resume my game by making my game thread(which holds/synchronized with surfaceview)  wait/notifyAll. This all runs well using the in game pause button.</p>
  
  <p>However, when I click home/back button I am able to pause my game, but when I resumes my game by clicking on its icon, I receive non responsive game screen back to me.</p>
  
  <p>I have put logs on OnResume() method but nothing gets printed in LogCat!
  If I click on my game screen I get error dialog to "Force Close" or "Wait" on my game activity.</p>
  
  <p>Why I am getting this non responsive screen as if my application Hangged after pause ?
  How can I handle physical buttons in same way as inGame pause/resume button ?</p>
  
  <p>here is my logcat view of the operation. you can see onResume sop not getting printed similar to onPause.</p>
  
  <p><img src="https://i.stack.imgur.com/EKlrw.png" alt="LogCat View"> </p>
  
  <p>EDIT : Code called by my pause/resume button and by onPause/onResume functions
  where "this" is thread class itself</p>
  
  <pre><code>protected void setPause(){
          synchronized (this) {
              isPaused = true;
                  }
      }
  
      protected void setResume(){
          synchronized (this) {
              isPaused = false;
              this.notifyAll();
          }
      }
  </code></pre>
  
  <p>Game Loop Code :</p>
  
  <pre><code>synchronized (this) {
              while (running) {
                  if (isPaused) {
                      try {
                          this.wait();
                      } catch (InterruptedException e) {
                          // TODO Auto-generated catch block
                          e.printStackTrace();
                      }
                  } else {
                      Canvas c = null;
  
                      try {
                          c = view.getHolder().lockCanvas();
                          synchronized (view.getHolder()) {
                              view.onDraw(c);
                          }
                      } catch (Exception e) {
                          // TODO Auto-generated catch block
                          e.printStackTrace();
                      } finally {
                          if (c != null) {
                              view.getHolder().unlockCanvasAndPost(c);
                          }
                      }
                      sleepTime = ticksPS
                              - (System.currentTimeMillis() - startTime);
                      try {
                          if (sleepTime &gt; 0)
                              sleep(sleepTime);
                          else
                              sleep(10);
                      } catch (Exception e) {
                          // TODO Auto-generated catch block
                          e.printStackTrace();
                      }
                  }
              }
          }
  </code></pre>
  
  <p>This how I am calling it from surface view :</p>
  
  <pre><code>public void surfaceCreated(SurfaceHolder holder) {
  
                  // start the game loop
                  System.out.println("Starting Game Loop @@@@@@@@@");
                  if(isPaused){
                      System.out.println("GamePaused");
                      gameLoopThread.setResume();
                  }
                  else{
                      System.out.println("Game Starting");
                      gameLoopThread.setRunning(true);
                  }
                  gameLoopThread.start();
  
              }
  </code></pre>
  
  <p>EDIT 2:
  If I Pause my game using pause button and let my phone get locked automatically... after resuming I am able to play normally with out any issue.
  As per logs I see surface destroyed is not getting called in this case.</p>