I want to know when my thread dies and, after this, execute some code.
I'm using a while
but my program is showing a bad execution.
The command while is holding the program.
Here is my code:
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");
}