gpt4 book ai didi

java - 退出 Action 监听器

转载 作者:行者123 更新时间:2023-12-01 15:00:33 25 4
gpt4 key购买 nike

如何从 Action 监听器中退出我的程序。我有两个线程,线程1和线程2。一个线程处于 ActionListener 中。但我希望另一个线程退出此 Action 监听器并管理其余代码。我该怎么做?

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()将是你最好的选择。

关于java - 退出 Action 监听器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13714922/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com