this.producer = producer; this.name = name;
Producer producer = new Producer( ); producer.start( ); // start two this time new NamedConsumer( "One", producer ).start( ); new NamedConsumer( "Two", producer ).start( );
try { while ( true ) { String message = producer.getMessage( ); System.out.println(name + " got message: " + message); sleep( 2000 ); } } catch( InterruptedException e ) { }