JDK 1.4 on WinXP. I have 2 threads started from the main thread. I would
like to print some status of the child threads from the main thread
periodically. But I dont see the main thread to print out anything when the
child threads are running. The child threads do sleep after some work.
Instead should I make the child threads wait() and make the main thread
notifyAll() after printing ?
public class MainThread {
WorkerThread t1, t2;
public static void main(String[] args) {
new MainThread().st art();
}
public void start() {
t1 = new WorkerThread();
t2 = new WorkerThread();
t1.start();
t2.start();
// even this is not printed...
System.out.prin tln("print");
printWorkerStat us();
}
public void printWorkerStat us() {
while ( t1.isAlive() || t2.isAlive() ) {
t1.printStatus( ); // this print never happens
t2.printStatus( ); // this print never happens
Thread.sleep(40 *1000);
}
}
}