How do I exit my program from an actionlistener. I have two threads, thread1 and thread2. One thread is in actionlistener. but i want the other thread to exit this actionlistener and manage rest of the code.. How can I do it?
sendtkttgt.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
Thread thread1= new Thread(){
public void run(){
SendingLogictoTGT obj=new SendingLogictoTGT();
try {
try {
obj.main(null);
} catch (InterruptedException ex) {
}
} catch (IOException ex) {
// System.exit(1);
}
}
};
/*Thread thread2= new Thread(){
public void run(){
//I want to exit from this actionlistener
}
};
*/
thread1.start();
}
});
interrupt() would be your best choice.