Advertisement
Ankhwatcher

Stop Runnable

Mar 27th, 2013
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.53 KB | None | 0 0
  1. public Runnable mUpdate = new Runnable() {
  2.         public void run() {
  3.             while (nowRunning) {
  4.                 synchronized (this) {
  5.                     try {
  6.                         wait();
  7.                     } catch (InterruptedException e) {
  8.  
  9.                         e.printStackTrace();
  10.                     }
  11.                 }
  12.                 runOnUiThread(new Runnable() {
  13.                     @Override
  14.                     public void run() {
  15.                         drawPlaces();
  16.                     }
  17.                 });
  18.             }
  19.         }
  20.     };
  21.  
  22. //Tell runnable to stop waiting
  23.     @Override
  24.     protected void onPause() {
  25.         super.onPause();
  26.         nowRunning = false;
  27.         synchronized (mUpdate) {
  28.             mUpdate.notify();
  29.         }
  30.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement