This repository contains code from an old University Assignment on Concurrency. We represent a road with multiple intersections, where cars must wait for their turn. There is no unnecessary waiting; cars will always go as soon as possible as long as the road is secure (no chance for collision). The waiting is solved through Java's Semaphores: each car acquires and releases the appropriate semaphores at the proper time. Note that some intersections require multiple Semaphores, and the procedure is not straightforward (check development notes at the bottom).
I've unfortunately lost the development git history, so it starts with the complete working code. I did some slight refactoring to improve the code somewhat, but I am neither a GUI nor Java developer, so I don't think this code is of any great quality.
Although it uses Maven, I am not sure how easy it is to run the project, so here are some videos for showcasing.
Squares represent cars, and each route is the road's part with its respective primary color. There are clockwise and counter-clockwise routes.
All cars at slow speed
cars_slow.mp4
All cars at full speed
cars_full_speed.mp4
Some fast, some slow
cars_mixed.mp4
When I try to change the speeds during the video, it gets laggy, so I've done separate videos instead of a big one.