내 스레드가 죽으면 이것을 알고 몇 가지 코드를 실행하고 싶습니다.어떻게 스레드를들을 수 있습니까?
나는 while
을 사용하고 있지만 프로그램이 잘못 실행 중입니다.
while 명령이 프로그램을 보유하고 있습니다. ,
public class Thread_para_Menu extends Thread {
public void run() {
System.out.println("executando thread");
for (int i = 0; i < 100; i++) {
try {
Thread.sleep(200);
} catch (InterruptedException ex) {
Logger.getLogger(Teste_Inicio.class.getName()).log(Level.SEVERE, null, ex);
}
if (i % 2 == 0) {
jlblAguarde.setForeground(Color.yellow);
} else {
jlblAguarde.setForeground(Color.orange);
}
}
System.out.println("FIM DO RUN");
}
}
public void Pisca_Menu() {
int xx =0;
Thread_para_Menu TEMPO_MENU = new Thread_para_Menu();
TEMPO_MENU.start();
while (TEMPO_MENU.isAlive()){
System.out.println("THREAD VIVE");
}
System.out.println("THREAD MORREU");
}
[Java 대기 스레드 종료] (https://stackoverflow.com/questions/4691533/java-wait-for-thread-to-finish) – Tom
Re, "...하지만 내 프로그램은 다음과 같습니다. 나쁜 실행을 보여줍니다. " 오류 메시지를 이해하는 데 도움이 필요하면 질문에 메시지를 포함시켜야합니다. –
팁 주셔서 감사합니다. – Rodrigo