/*
 * Fork.java (Implements Synchronized Fork for DP.)
 *
 * Written by : Nitin Jeevan Motgi (nmotgi@cs.ucf.edu)
 *
 * 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.
 *
 * No revision History.
*/

class Fork{
  private boolean is_free;

  Fork(){
    is_free = true;
  }/* End Fork.*/
  
  public synchronized void Take(){
    while (!is_free)
     try{
      wait();
     }catch(InterruptedException e){}
     
    is_free = false;
  }/* End of Take.*/

  public synchronized void Leave(){
    is_free = true;
    notify();
  }/* End of Leave.*/
}/* End of Fork.*/



