Update TrafficLightThread

This commit is contained in:
Gaa56
2025-11-05 13:21:10 +00:00
parent 0e5526c3f6
commit 484cba1eee

View File

@@ -10,10 +10,6 @@ import sd.model.Vehicle;
* Implements the control logic for a single TrafficLight
* as a Runnable task that runs in its own Thread.
*
* This class fulfills the assignment requirements:
* 1. Implements Runnable (to be executed by a Thread/ExecutorService).
* 2. Implements the GREEN/RED cycle logic.
* 3. Includes a graceful shutdown mechanism (via the 'running' flag).
*/
public class TrafficLightThread implements Runnable {
@@ -120,11 +116,11 @@ public class TrafficLightThread implements Runnable {
vehicle.addCrossingTime(crossingTime); //
// 4. Update intersection statistics
// (This requires getIntersection() to be public in IntersectionProcess)
process.getIntersection().incrementVehiclesSent(); //
// 5. Call the parent Process to send the vehicle
// (This requires sendVehicleToNextDestination() to be public in IntersectionProcess)
process.sendVehicleToNextDestination(vehicle); //
}
}
@@ -158,8 +154,5 @@ public class TrafficLightThread implements Runnable {
*/
public void shutdown() {
this.running = false;
// (Note: If the thread is sleeping, it will only stop
// *after* waking up. A more immediate shutdown would require
// calling .interrupt() on the thread running this Runnable)
}
}