Grokking Multithreading and Concurrency for Coding Interviews
0% completed
Problem 17: Traffic-Light-Controlled Intersection Synchronization
Overview
The problem at hand is to ensure the smooth and safe movement of vehicles and pedestrians through a four-way intersection using traffic lights. Each direction of vehicle traffic and each direction of pedestrian traffic is represented as an individual thread, resulting in a total of eight threads. The challenge lies in synchronizing these threads such that there's no collision, and the flow is efficient.
Concurrency & Synchronization Insights
1
.....
.....
.....
Like the course? Get enrolled and start learning!
Salih Boshnak
· a year ago
pedestrians and vehicles can pass concurrently in a + intersection shape your solution does not implement this
Salih Boshnak
· 4 months ago
locking is redundant in your solution only one thread is locking it
this question is misleading please consider refactoring it