I am working on a task and have to create two classes, one representing a person and the other a bridge. Only one person can "cross" the bridge at any time, but there may be people waiting for the intersection.
I easily implemented this with multithreading, allowing several people to intersect at once, but I am having trouble changing it, allowing only one thread to run ...
My main problem is the design of the class that they need, I have to start streams inside the person class, but the bridge class must be able to wait and notify them of start / stop
Any ideas how I can do this?
source share