FileDocCategorySizeDatePackage
Consumer.javaAPI DocExample656Sat Apr 23 22:35:36 BST 2005None

Consumer

public class Consumer extends Object implements Runnable

Fields Summary
Producer
producer
Constructors Summary
Consumer(Producer producer)

        this.producer = producer;
    
Methods Summary
public static voidmain(java.lang.String[] args)

        Producer producer = new Producer();
        new Thread( producer ).start();
        Consumer consumer = new Consumer( producer );
        new Thread( consumer ).start();
    
public voidrun()

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