Regards,<BR>Shree
class Waiter extends Thread {
public synchronized void run() {
try {
Thread notifyThread = new Thread(new Notifier());
notifyThread.start();
wait();
}
catch (InterruptedException ie) {
System.out.println("Interrupted.");
}
System.out.println("Waiter back in control.");
}
}
class Notifies extends Thread {
public synchronized void run() {
System.out.println("Notifier running.");
try {
System.out.println("Going to sleep.");
Thread.sleep(100);
System.out.println("Woke up.");
}
catch (InterruptedException ie) {
System.out.println("Interrupted.");
}
System.out.println("Back to waiter.");
notifyAll();
}
}
public class Waiting {
public static void main(String[] args) {
Thread waitThread = new Thread(new Waiter());
waitThread.start();
}
}
SCJP
Visit my download page
SCJP
Visit my download page
SCJP
Visit my download page
Jane Griscti
SCJP, Co-author Mike Meyers' Java 2 Certification Passport
....
SCJP
Visit my download page
....
Jane Griscti
SCJP, Co-author Mike Meyers' Java 2 Certification Passport
SCJP
Visit my download page
Destiny's powerful hand has made the bed of my future. And this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
|