FileDocCategorySizeDatePackage
NamedConsumer.javaAPI DocExample800Mon May 01 14:41:42 BST 2000None

NamedConsumer

public class NamedConsumer extends Thread

Fields Summary
Producer
producer
String
name
Constructors Summary
NamedConsumer(String name, Producer producer)

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

        Producer producer = new Producer(  );
        producer.start(  );

        // start two this time
        new NamedConsumer( "One", producer ).start(  );
        new NamedConsumer( "Two", producer ).start(  );
    
public voidrun()

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