Check whether the thread has been interrupted in the run method,if so, mannually write some codes to close your GUI window.
About how to terminate a JFrame window, please refer to relevant API.
Any questions, please let me know.
The interrupt method of class Thread never helps you terminate immediately the running of the thread.It only sets a flag which you can make use of to make logic judgement in the code.
In order to implement the fuction of terminating the thread after calling the interrupt method,you can refer to the following code:
public static void main(String[] args) throws Exception {
Thread t1 = new Thread(new Runnable(){
@Override
public void run() {
System.out.println("task start...");
for( int k = 0;k<100;k++){
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
if(Thread.currentThread().isInterrupted()){
System.out.println("interrupt");
break; // exit the loop
}else{
System.out.println("k:"+k);
}
}
System.out.println("task end ...");
}
});
t1.start();
Thread.sleep(5000);
t1.interrupt();
Thread.sleep(100000);
}