I create an alarm clock that rings an alarm until the puzzle is solve I have a play class that play alarm ` package clock;
import java.applet.Applet;
import java.applet.AudioClip;
import java.net.URL;
import javax.swing.*;
public class Play {
AudioClip ac;
Thread t;
public void playSound(int n)
{
try {
URL url = new URL("file:1.wav" );
ac = Applet.newAudioClip(url);
t= new Thread(){
public void run(){
ac.loop();
}
};
if(n==0){
t.start();
}
if (n==1){
JOptionPane.showMessageDialog(null,"OFF");
ac.stop();
t.interrupt();
}
}
catch (Exception e) {
JOptionPane.showMessageDialog(null,e);
}
}`
it play alarm on time but when i call it with parameter 1 it shows "OFF" but alarm thread is not stop