import org.javasim.SimulationProcess; import java.lang.*; public class Resource { /** * Class for critical resource that can be Reserved and Liberated and manages itself the required waiting list */ public Resource (int number) { Waiting= new ProcessQueue(); Capacity= number; UsedCapacity=0; } public Resource () { Waiting= new ProcessQueue(); Capacity= 1; UsedCapacity=0; } public boolean IsEmpty () { if (Waiting.IsEmpty()) return true; else return false; } public long QueueSize () { return Waiting.QueueSize(); } public boolean IsBusy() { if(UsedCapacity==Capacity) return true; else return false; } public boolean Reserve(SimulationProcess Client2) { if ((Waiting.QueueSize()==0) && (UsedCapacity