title: does java thread have to invoke stop
body: <p>I have a button that starts a thread, which i use to show that my system is processing.
  with <code>thread1</code> i open a jdialog and to Show that my system is running. whereby i use <code>thread2</code> to close my jdialog with <code>dlg.dispose();</code>
  my problem is, once my program stops running, i click the button again, then an error message occurs, telling me that my thread has a problem.</p>
  
  <p>I have another button without a thread behind and it performs the action perfectly if I click it another time.</p>
  
  <p>Can somebody tell me where the problem is? I tried to close the thread by using <code>Thread.currentThread().stop();</code> but it still does not work.</p>
  
  <p>Here is my sample code,</p>
  
  <pre><code>private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
  
          if(chooser == null){
             String message = "No file chosen. Please choose your file.";
          JOptionPane.showMessageDialog(new JFrame(), message, "WiresharkHelper",
          JOptionPane.ERROR_MESSAGE); 
          }
          else if(chooser != null){
          jTabbedPane4.setSelectedIndex(1);
          thread1.start();
          thread2.start();
          }
      }
  JOptionPane opt = new JOptionPane("Application is running", JOptionPane.WARNING_MESSAGE, JOptionPane.DEFAULT_OPTION, null, new Object[]{});//I put this in global for my thread2 to dispose my dialog
      JDialog dlg = opt.createDialog("Warning");
      Thread thread2 = new Thread () {
    public void run () {
          dlg.setVisible(true);
    }
  };
      Thread thread1 = new Thread () {
    public void run () {
      //code running
      dlg.dispose();
    }
  };
  </code></pre>