class consumer extends Thread { producer myprod; String name; consumer(String initname,producer initprod) { this.myprod=initprod; this.name=initname; } public void run() { try { sleep(2000); // allow producer head start while (true) { String message=myprod.getMessage(); System.out.println(name+" got message: "+message); sleep(2500); } } catch(InterruptedException e) { } } }