/*****************************************************************
 * Memorial University of Newfoundland<br>
 * 8893 Concurrent Programming<br>
 * Assignment 3, Question 2 - Student Class 
 *
 * @author Dennis Peters
 * @version 2002.02.28
 ****************************************************************/
class Student implements Runnable 
{
  private assign3_Bartender server; // Shared by all students and the Runner
  int myId; // student Id

  public Student(assign3_Bartender s, int id)
    { server = s; myId = id; }

  public void run()
  {
    while (true)
    {
      System.out.println("Student " + myId + " is Thirsty.");
      server.getBeer(myId);
      System.out.println("Student " + myId + " is drinking.");
      drink();
    }
  }

  private void drink()
  {
    try {
      Thread.sleep((int)Math.round(Math.random()*50));
    }
    catch (InterruptedException e) {}
  }
}

