notes when the server finishes serving the customerthat customer departs if the queue is not emptythe server immediately commences serving the next customer otherwisethe server becomes idle how do you keep track of which event to simulate nexteach event (arrival or departureoccurs at discrete point in simulation time in order to ensure that the simulation program is correctit must compute the events in order this is called the causality constraint-events cannot change the past in our modelwhen the server begins to serve customer you can compute the departure time of that customer sowhen customer arrives at the server schedule an event in the future which corresponds to the departure of that customer in order to ensure that events are processed in orderyou keep them in priority queue in which the time of the event is its priority since you always process the pending event with the smallest time next and since an event can schedule new events only in the futurethe causality constraint will not be violated implementation this section presents the simulation of system comprised of single queue and server as shown in figure program defines the class event which represents events in the simulation there are two parts to an eventa type (either arrival or departure)and time public class simulation static class event extends association public static final int arrival public static final int departure event (int typedouble time{super (new db (time)new int (type))double gettime ({return ((db getkey ()doublevalue ();int gettype ({return ((intgetvalue ()intvalue ();/program event class an association is an ordered pair comprised of key and value in the case of the event classthe key is the time of the event and the value is the type of the event thereforethe events in priority queue are prioritized by their times program defines the run method which implements the discrete event simulation this method takes one argumenttimelimitwhich specifies the total amount of time to be simulated the simulation class contains single fieldcalled eventlistwhich is priority queue this priority queue is used to hold the events during the course of the simulation public class simulation priorityqueue eventlist new leftistheap ()public void run (double timelimit lovely professional university