001package edu.pdx.cs410J.net;
002
003/**
004 * A <code>McCustomer</code> arrives a <code>McDonalds</code> and
005 * waits for a BigMac.
006 */
007public class McCustomer implements Runnable {
008  private String name;
009  private McDonalds mcDonalds;
010
011  /**
012   * Creates a new <code>McCustomer</code>
013   */
014  public McCustomer(int id, McDonalds mcDonalds) {
015    this.name = "Customer " + id;
016    this.mcDonalds = mcDonalds;
017  }
018
019  /**
020   * Go to a <code>McDonalds</code> and wait for a BigMac
021   */
022  public void run() {
023    System.out.println(this.name + " wants a BigMac");
024
025    try {
026      synchronized(this.mcDonalds) {
027        this.mcDonalds.wait();
028      }
029
030    } catch (InterruptedException ex) {
031      return;
032    }
033
034    System.out.println(this.name + " got a BigMac");
035  }
036
037}