public void run() { try { while (!Thread.interrupted()) { // Blocks until next piece of toast is available: Toast t = dryQueue.take(); t.butter(); print(t); butteredQueue.put(t); } } catch (InterruptedException e) { print("Butterer interrupted"); } print("Butterer off"); }
public void run() { try { while (!Thread.interrupted()) { // Blocks until next piece of toast is available: Toast t = finishedQueue.take(); // Verify that the toast is coming in order, // and that all pieces are getting jammed: if (t.getId() != counter++ || t.getStatus() != Toast.Status.JAMMED) { print(">>>> Error: " + t); System.exit(1); } else print("Chomp! " + t); } } catch (InterruptedException e) { print("Eater interrupted"); } print("Eater off"); }