steffunator
Programmer
Hello, I have a simple program that I have to build using threads and Jframe forms. I wish the second part were different, but that's how it was assigned.
Anyway, the program consists of using three different threads to call their corresponding window. Then using join() to kill them. The program cannot be finished until all three windows are closed...
For some reason when I click to close on any of the frames, they will all close at the same time. Each of them has its own JFrame form, so I'm not sure why this happens.
This is my code:
public class NewMain
{
/**
* @param args the command line arguments
*/
public static void main(String[] args)
{
Reporte heredia = new Reporte();
Reporte1 alajuela = new Reporte1();
Reporte2 cartago = new Reporte2();
Thread alaj = new Thread(alajuela);
Thread here = new Thread(heredia);
Thread cart = new Thread(cartago);
alaj.start();
here.start();
cart.start();
if (alaj.isAlive() && here.isAlive() && cart.isAlive()) {
try {
alaj.join();
here.join();
cart.join();
System.out.println("End.");
} catch (InterruptedException excepcion) {
System.out.println("Error.");
}
}
}
}
Anyway, the program consists of using three different threads to call their corresponding window. Then using join() to kill them. The program cannot be finished until all three windows are closed...
For some reason when I click to close on any of the frames, they will all close at the same time. Each of them has its own JFrame form, so I'm not sure why this happens.
This is my code:
public class NewMain
{
/**
* @param args the command line arguments
*/
public static void main(String[] args)
{
Reporte heredia = new Reporte();
Reporte1 alajuela = new Reporte1();
Reporte2 cartago = new Reporte2();
Thread alaj = new Thread(alajuela);
Thread here = new Thread(heredia);
Thread cart = new Thread(cartago);
alaj.start();
here.start();
cart.start();
if (alaj.isAlive() && here.isAlive() && cart.isAlive()) {
try {
alaj.join();
here.join();
cart.join();
System.out.println("End.");
} catch (InterruptedException excepcion) {
System.out.println("Error.");
}
}
}
}