Hey, I'm trying this for a couple of hours now.
Following scenario: I have 3 threads -> Thread A, B and Z and one semaphore starting with 0. Letting both Threads (A and B) wait on this semaphore.
Lets assume A and B are cars and Z is an employee changing the tyres of A and B by simply changing a boolean (tires_changed) to true.
Whenever Z has changed the tires of a Thread/Car the boolean of this specific thread is set to true and the global semaphore incremented by one.
Now the problem where I'm stuck at.
Whats the best way to check in the specific thread (A and B) if the tires has been changed. I mean if the tires arn't changed for thread A it has to wait, increase semaphore and let Thread B check.
Hope I explained everything well enough 🙂