title: Android finish Thread
body: <p>I want to finish Thread. <code>ProgressBar</code> progress will 0 and Thread will close when button clicked. I used <code>destroy()</code>, <code>stop()</code>, <code>resume()</code>, <code>interrupt()</code> but doesnt work. How I can finish Thread?</p>
  
  <pre><code> class TIME implements Runnable {
      @Override
      public void run() {
  
          for (int i=0; i&lt;10; i++) {
              try {
                  Thread.sleep(100);
              } catch (InterruptedException e) {
                  e.printStackTrace();
              }
              handler.post(new Runnable() {
                  @Override
                  public void run() {
                      progressBar.setProgress(i);
                      if(i==9){Log.i("Log","Time's Up!");}
                  }
              });
          }
      }
  }
  </code></pre>
  
  <h2>in onCreate()</h2>
  
  <pre><code>new Thread(new TIME()).start();
  ProgressBar progressBar=(ProgressBar)findViewById(R.id.progressBar1);
  progressBar.setMax(2000);
  Button bt=(Button)findViewById(R.id.button1);
  bt.setOnClickListener(new OnClickListener() {
          @Override
          public void onClick(View v) {
            //TIME thread will finish. And progressBar.setProgress(0);
          }
      });
  </code></pre>