this.producer = producer;
Producer producer = new Producer(); new Thread( producer ).start(); Consumer consumer = new Consumer( producer ); new Thread( consumer ).start();
while ( true ) { String message = producer.getMessage(); System.out.println("Got message: " + message); try { Thread.sleep( 2000 ); } catch ( InterruptedException e ) { } }