title: unable to destroy activity when trying stop not running thread
body: <p>I am bit confused with threads i made. I have several threads running, and some activity creates and cleans a new thread. So now when I try to exit application I use aboart. I checked/ when thread is running its closed fine. But when not I get errors and "... 11 more"... any Idea what am i doing wrong?</p>
  
  <pre><code>    public void run() {
      while (abort_) {
          //doeing stuff
          } 
      }
  
  
  synchronized public void abort() {
      abort_ = true;
      if (ioio_ != null) {
          ioio_.disconnect();
      }
  }
  </code></pre>
  
  <p>When Main() is destroid:</p>
  
  <pre><code>public void onDestroy() {
      super.onDestroy();
      Start_settings.stopSetThread();
      bool = false; //stop screanThrea
          if(ioio_thread_.isAlive()){
                ioio_thread_.abort();
          }
  }
  </code></pre>
  
  <p>so when onDestroy() method is called its throuws:
  UPDATED i missed the line:</p>
  
  <pre><code>W/dalvikvm(8672): threadid=1: thread exiting with uncaught exception (group=0x40018578)
  
  
  
  E/AndroidRuntime(8191): FATAL EXCEPTION: main
  E/AndroidRuntime(8191): java.lang.RuntimeException: Unable to destroy activity {android.io/android.io.Main}: java.lang.NullPointerException
  E/AndroidRuntime(8191):     at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:2676)
  E/AndroidRuntime(8191):     at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:2694)
  E/AndroidRuntime(8191):     at android.app.ActivityThread.access$2100(ActivityThread.java:117)
  E/AndroidRuntime(8191):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:968)
  E/AndroidRuntime(8191):     at android.os.Handler.dispatchMessage(Handler.java:99)
  E/AndroidRuntime(8191):     at android.os.Looper.loop(Looper.java:130)
  E/AndroidRuntime(8191):     at android.app.ActivityThread.main(ActivityThread.java:3687)
  E/AndroidRuntime(8191):     at java.lang.reflect.Method.invokeNative(Native Method)
  E/AndroidRuntime(8191):     at java.lang.reflect.Method.invoke(Method.java:507)
  E/AndroidRuntime(8191):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
  E/AndroidRuntime(8191):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
  E/AndroidRuntime(8191):     at dalvik.system.NativeStart.main(Native Method)
  E/AndroidRuntime(8191): Caused by: java.lang.NullPointerException
  E/AndroidRuntime(8191):     at android.kvisio.Main.onDestroy(Main.java:364)
  E/AndroidRuntime(8191):     at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:2663)
  E/AndroidRuntime(8191):     ... 11 more
  </code></pre>
  
  <p>I solved my problem by putting flags when thread is started and checking the flags instead of thread.isAlive() method. But my question remains: 
  Why when I check not running thread with thread.isAlive() it throws this kind of exceptions?
  thanks for your time.</p>