FileDocCategorySizeDatePackage
Consumer.javaAPI DocExample728Tue May 04 09:43:44 BST 2004com.oreilly.tiger.ch10

Consumer

public class Consumer extends Thread

Fields Summary
private BlockingQueue
q
private PrintStream
out
Constructors Summary
public Consumer(String name, BlockingQueue q, PrintStream out)

    setName(name);
    this.q = q;
    this.out = out;
  
Methods Summary
private voidprocess(java.lang.Object obj)

    out.printf("%s processing object:%n         '%s'%n", 
                getName(), obj.toString());
  
public voidrun()

    try {
      while (true) {
        process(q.take());
      }
    } catch (InterruptedException e) {
      out.printf("%s interrupted: %s", getName(), e.getMessage());
    }