Imagine that threads represent ballroom dancers and that two kinds of dancers, leaders and followers, wait in two queues before entering the dance floor. When a leader arrives, it checks to see if there is follower waiting. If so, they can both proceeds. Otherwise it waits.
Similarly, when a follower arrives, it checks for a leader and either proceeds or waits, accordingly.
At a time there will be a single pair doing the dance. Once a pair leave, the other pair enters. As shown in the diagram.
We will have the following ballroom class -
Similarly, when a follower arrives, it checks for a leader and either proceeds or waits, accordingly.
At a time there will be a single pair doing the dance. Once a pair leave, the other pair enters. As shown in the diagram.
We will have the following ballroom class -