thread priority question...
- From: "Padhu Vinirs" <prabha_pady@xxxxxxxxxxx>
- Date: Wed, 8 Mar 2006 06:46:46 -0500
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().start();
}
public void start() {
t1 = new WorkerThread();
t2 = new WorkerThread();
t1.start();
t2.start();
// even this is not printed...
System.out.println("print");
printWorkerStatus();
}
public void printWorkerStatus() {
while ( t1.isAlive() || t2.isAlive() ) {
t1.printStatus(); // this print never happens
t2.printStatus(); // this print never happens
Thread.sleep(40*1000);
}
}
}
.
- Follow-Ups:
- Re: thread priority question...
- From: Dobromir Gaydarov
- Re: thread priority question...
- From: Marek Puchalski
- Re: thread priority question...
- Prev by Date: Re: map algorithm question
- Next by Date: Re: thread priority question...
- Previous by thread: Re: max size of virtual memory
- Next by thread: Re: thread priority question...
- Index(es):
Relevant Pages
|
|