/* * BoundedBufferPMon.java (Implements Producer Using Monitors). * * Written by : Nitin Motgi (nmotgi@cs.ucf.edu) * * This file basically implements Producer using Monitors. * * Portions copyright(c) 2000 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 authors. * * $Id : BoundedBufferPMon.java, v1.0.0 02/07/2001. $ * * Revision History: * * 1. Created by. Nitin, v1.0.0 02/07/2001. * 2. Added Documenttaion, Nitin, v1.0.1 02/09/2001. */ /* Start of BoundedBufferPMon.*/ public class BoundedBufferPMon extends Thread{ /* Each producer is given an ID so that the higher level routine can interact with a specific processor.*/ int nID; /* This is up level pointer points to the parent class which provides mechanism for synchronization.*/ BoundedBufferMon BBMon; /* End condition indicator set to push the Producer from endlessly producing an item and put in the queue.*/ boolean bEndCondition; /* * This function is constructor for this class. */ public BoundedBufferPMon(int nID,BoundedBufferMon BBMon){ this.nID = nID; /* Store ID.*/ this.BBMon = BBMon; /* Pointer to Higher class.*/ bEndCondition = true; /* Produce one item and put in shared data structure.*/ }/* End of BoundedBufferPSem.*/ /* * This program is heart of this thread. */ public void run(){ /* Till the indicator turns false.*/ while(bEndCondition){ /* SIMULATE PRODUCING AN ITEM.*/ BBMon.Insert(1,this); }/* End of while.*/ }/* End of run.*/ /* * Sets the end codition to true or false. */ public void SetEndCondition(boolean bState){ bEndCondition = bState; }/* End of SetEndCondition.*/ }/* End of BoundedBufferPMon.*/