/** * The main loop of the simulation. First call init() to get objects ready, * then go into the main loop, where {@link SimulatorEvent}s are handled removed from * the {@link SimulatorEventQueue}, and new {@link SimulatorEvent}s are created and inserted * into the {@link SimulatorEventQueue}. * @throws IOException * @throws InterruptedException */ void run() throws IOException, InterruptedException { init(); for (SimulatorEvent next = queue.get(); next != null && next.getTimeStamp() < terminateTime && !shutdown; next = queue.get()) { currentTime = next.getTimeStamp(); assert(currentTime == queue.getCurrentTime()); SimulatorEventListener listener = next.getListener(); List<SimulatorEvent> response = listener.accept(next); queue.addAll(response); } summary(System.out); }