A desktop application developed in Java that simulates the distribution of clients (Tasks) to multiple queues (Servers) using various scheduling strategies.
- Time-Based Simulation: The application runs a discrete, step-by-step simulation cycle, defined by a user-set maximum time limit.
- Client/Task Generation: A specified number of clients (Tasks) are generated randomly, with arrival and service time intervals defined by the user in the GUI.
- Task Ordering: Generated tasks are sorted based on their arrival time (arrivalTime) before the simulation begins.
The application allows selection from two task distribution policies, managed by the Scheduler:
- SHORTEST_QUEUE: Tasks are dispatched to the Server (queue) with the smallest current number of waiting tasks.
- SHORTEST_TIME: Tasks are dispatched to the Server with the minimum total current waiting period (waitingPeriod).
- Graphical User Interface (GUI): A Swing interface allows configuration of all simulation parameters (Client Count, Queue Count, Time Limit, Strategy, Arrival/Service Time Ranges).
- Real-Time Visualization: The interface visually updates the state of the queues (Servers) and the waiting tasks at every time step.
- Event Logging: All simulation events (state of queues and waiting tasks at each second) are logged to an output file named LogOfEvents.txt.
- Language: Java
- Graphical Interface: Swing (AWT/Swing)
- Multi-threading: Each queue (Server) runs on its own separate thread (Thread).
- Concurrency: Uses concurrent structures like BlockingQueuefor tasks andAtomicIntegerfor managing the waiting period within theServerclass.
- Design Pattern: Implements the Strategy pattern (Strategy,ShortestQueueStrategy,TimeStrategy) for flexible task allocation.
- Model:- Task.java: Represents a client, implementing- Comparablefor sorting by arrival time.
- Server.java: Represents a queue, handling tasks as a- Runnablethread.
 
- BusinessLogic:- SimulationManager: Main control class for the simulation lifecycle and task generation.
- Scheduler: Dispatches tasks using the selected- Strategy.
- StrategyInterface and Implementations: Defines the task allocation logic.
 
- GUI:- SimulationFrame.java: The Swing interface for configuration and real-time visualization.
 
- Ensure you have a JDK (Java Development Kit) installed.
- The main execution class is BusinessLogic.SimulationManager(which launches theSimulationFrame).
- The application will automatically create the LogOfEvents.txtfile in the root directory upon simulation completion.