/* WaitNotifyAll.java Burton Rosenberg Tue Jul 22 17:31:41 EDT 1997 A program to demonstrate wait/notify */ import java.io.* ; public class WaitNotify implements Runnable { final static int N = 5 ; final static int D = 1000 ; int id ; Object lock ; WaitNotify( int id, Object lock ) { this.id = id ; this.lock = lock ; } synchronized public void run () { try { while (true) { System.out.println( id ) ; synchronized ( lock ) { lock.wait() ; } } } catch ( InterruptedException ie ) { } } public static void main (String [] args) { Object lock = new Object() ; for ( int i=0; i