예제 #1
0
 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");
 }
예제 #2
0
 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");
 }