How about? I am a student and in one of the subjects that I have (concurrent programming) I am asked to perform an exercise. Which says that a series of threads (cars) come to a river and get on a boat (another thread) this boat crosses them from the shore, the ten cars that were inside the boat go down and the boat returns to the other shore (this it is repeated constantly until there are no more cars left on the original shore). I was able to solve this problem using Monitors, Semaphores and ReentrantLocks. Now, however, the teacher asks us to solve this exercise using any class of the java.util.concurrent packete (without using semaphores, monitors or locks).
I was reading a lot but I'm not finding a class or method to use.
I'm very lost. Any help would come in handy.
I wanted to use Phasers or CyclicBarriers ... or also BlockingQueues. but I need to eliminate active waits (the cars that wait for the ship to be full again must be waiting passively until the ship notifies them), make the threads warn when they can continue with their executions, etc. And I can not use the wait and notify (of object)
Thank you very much!