정상적으로 실행중인 스레드 (sleep() 또는 wait() 상태가 아님)를 인터럽트하려고합니다.Java에서 정상적으로 실행중인 스레드 인터럽트
그물을 통과하는 동안 정상적으로 실행중인 스레드를 방해하는 것은 플래그를 true로 설정하고 프로세스를 계속 진행하게됩니다. 내가 one.java에서 예외 블록을 얻을 수 있습니다 예외 : InterruptedException을 던질 때
코드는, two.java에서 two.java
.....
.....
stop method() throws InterruptedException{
if(!(t.isInterrupted())){
t.interrupt();
throw new InterruptedException();
}
}
에
one.java
......
......
actionperformedmethod {
if (actionCmd.equals("cancel")) {
try {
r1.stop(); // to two.java
} catch (InterruptedException ex) {
....
....
}
}
}
하지만, 그 스레드가 정상적인 프로세스를 계속하는 것처럼 보이기 때문에 스레드를 중지하는 방법은 무엇입니까? 도와주세요 개념 스레드 새로운
암 ..
는
이 당신에게 흥미있을 수 있습니다받을 때마다 http://stackoverflow.com/questions/10961714/how-to-properly -stop-the-thread-in-java? – Willmore