public class Sink extends Thread { private QBuffer in; private Person p; private boolean done; // constructor: initializes queue pointer and exit flag public Sink (QBuffer b) { // the parameter b points to the input queue in = b; done = false; } // get items from in queue and display them // quit when the Go Away message is spotted public void run () { while (! done) { if (! in.isEmpty()) { p= (Person) in.dequeue(); if (p.getName().compareTo("Go Away") == 0) { done=true; } else { System.out.println(p.toString()); } } else { yield(); } } System.out.println("Sink is done"); } }