title: Restarting a Finished Thread Causes Crash (Android SDK)
body: <p>The title pretty much explains the issue.</p>
  
  <p>I have a button that when I press toggles on/off this thread.  It turns it on and off successfully... once, then it crashes if I try to turn it on again.</p>
  
  <pre><code>private Thread dataThread = new Thread(new Runnable(){
      public void run() {
          while(transmitPackets){
                  Log.d("Test","DERP");
          }
      }
  });
  </code></pre>
  
  <p>and where its run...</p>
  
  <pre><code>toggleButton.setOnClickListener( new View.OnClickListener() {
          public void onClick(View v){
              transmitPackets = !transmitPackets;
              if( transmitPackets ) {
                  toggleButton.setText("Pause");
                  dataThread.start();
              }
              else {
                  toggleButton.setText("Transmit");
              }
          }
      });
  </code></pre>
  
  <p>transmitPackets is the boolean toggled by the button press.  Named as such because this app will eventually be sending data over a network. The thread uses it to terminate as well.</p>
  
  <p>The stack trace generated by the app crash isn't particularly helpful in figuring out how to fix it to me as it just says it crashed on restarting the thread--which was evident by the problem itself.                                                </p>
  
  <p>I'm new to the Android SDK and threading in Java both so I don't know where I could be going wrong.  This seems to be the simplest implementation of a thread possible which is where I'm starting before I try to do anything funky with the thread.</p>