thread checking problem
<p>I do need help.
I'm wracking my brain in order to understand how threads work.</p>

<p>I'm wondering what's wrong with this code?
My application has two threads. One thread starts when the user press button A, the other one
starts when the B button is chosen. If one button is enabled the other one is disabled.</p>

<p>Now I'd like to be able to warn the user that a thread is still running whenever he/she tries to
exit the program.</p>

<p>the code is....actually even though nothing is running the user is unable to exit..
Thank you very much</p>

<blockquote>
  <p>exitAction = new
  AbstractAction("Exit") {</p>

<pre><code>        public void actionPerformed(ActionEvent e) {

          Thread thRunning = Thread.currentThread();


        if (thRunning.isAlive()) {
</code></pre>
  
  <p>JOptionPane.showMessageDialog(ProgAu.this,
  "Be careful.Press STOP before
  exiting",
                      "Process running", JOptionPane.WARNING_MESSAGE);</p>

<pre><code>    }
     else {

            System.exit(0);}

        }
    };
</code></pre>
</blockquote>

<p>--
This is one of the thread I'm refering to....
What should I do in order to detect its behaviour?</p>

<blockquote>
  <p>class RecThread extends Thread {</p>

<pre><code>    public void run() {

        recFile = new File("rec.wav");

        AudioFileFormat.Type fileType = null;
        fileType = AudioFileFormat.Type.WAVE;



        try {

            targetDataLine.open(audioFormat);


            targetDataLine.start();


            AudioSystem.write(new AudioInputStream(targetDataLine),
</code></pre>
  
  <p>fileType, recFile);</p>

<pre><code>        } catch (Exception e) {
            showException(e);
        }


        playAction.setEnabled(true);
        stopPlayAction.setEnabled(false);
  recAction.setEnabled(true);
        stopRecAction.setEnabled(false);  




    }
}
</code></pre>
</blockquote>
