-3
어떻게 Java 프로그래밍에서 threaddeath 예외를 시뮬레이트 할 수 있습니까? 어떤 시나리오에서 발생합니까? 예를 들어 threaddeath 예외를 던질 수 있습니다.Java에서 ThreadDeath 예외 Simimting
감사 :이 한 ThreadDeath를 슬로우하는 예입니다
public class ThreadDeathCatch {
public static void main(String[] args) {
try {
Thread t = new Thread() {
public void run() {
try {
Thread.sleep(2500);
} catch (Throwable ex) {
ex.printStackTrace();
System.out.println("Caught in run: " + ex);
}
}
};
t.start();
// Give t time to get going...
Thread.sleep(1000);
t.stop(); // EXPECT COMPILER WARNING
} catch (Throwable t) {
System.out.println("Caught in main: " + t);
}
}
}
, 그것은 스레드의 죽음이
Thread.stop를 사용하지 않고 다중 스레드 환경에서 발생할 수있는 다른 잘못된 시나리오가 Thread.stop를 사용의견이 있으십니까? 질문의
적어도 절반 http://download.oracle.com/javase/7/docs/api/java/lang/ThreadDeath [은'ThreadDeath' 문서를 (읽고 답변을 얻을 수 있습니다 .html). –
귀하의 * 구체적 * 질문은 무엇입니까? – Bhaskar
threaddeath 예외를 throw하는 라이브 프로그램이 필요합니다 – anish