/*
 * Philosopher.java (Implements Philosopher)
 *
 * Written By : Nitin Jeevan Motgi (nmotgi@cs.ucf.edu)
 *
 * This class implements Philosopher.
 *
 * Portions copyright(c) 2001 to School of Electrical Engineering and 
 * Computer Science, UCF, Orlando.
 *
 * Use and distribution of this source code are strictly governed by
 * terms and conditions set by the author.
 *
 * $Id : Philosopher.java v1.0.0  02/09/2001.
 *
 * Revision History:
 * 1. Created Basic Structure           Nitin           02/09/2001.                                
 * 2. Documentation Added               Nitin           02/09/2001.
 * 3. Final Documentation Check         Nitin
 * 4. Final Variable Name Check         Nitin
 * 5. Final Functionality Check         Nitin
*/

/*****************************************************************************
 * Philosopher
 * Description : Simulates Philosopher (Single)
 * Functions
 * 1. Philosopher(Fork fLeft, Fork fRight,int nID,DiningPhilosopher DPhil) and
 * 2. public void SetEndCondition(boolean bState){
 ****************************************************************************/
class Philosopher extends Thread{
  public Fork left;                     /* Left Fork of the Philosopher.*/
  public Fork right;                    /* Right one.*/
  public int  nID;                      /* Philosopher ID.*/
  private DiningPhilosopher DPhil;      /* Handle of Creating class.*/        
  private boolean bEndCondition;        /* To Terminate Philosopher.*/
  
  /* Default Constructor.*/
  Philosopher(Fork fLeft, Fork fRight,int nID,DiningPhilosopher DPhil){
    left = fLeft;
    right = fRight;
    this.nID = nID;
    this.DPhil = DPhil;
    bEndCondition = true;
  }/* End of Philosopher.*/

  /* Philosopher Heart.*/
  public void run(){
    while (bEndCondition) {
      DPhil.Eat(this);
      DPhil.Think(this);
    }/* End of While.*/
  }/* End of run.*/

  /*  Sets the End condition for grace full death of the loop. */
   public void SetEndCondition(boolean bState){
    bEndCondition = bState;
   }/* End of SetEndCondition.*/

}/* End of Philosopher.*/


