I need to achieve multiple producer and one consumer problem.
The restriction is i have two producers and one consumer. The consumer should start processing only when it gets notification from both the producers. until then consumer shouldn’t do anything. but each producer work independently and they can keep on producing. Could you please assist me in doing this.
HSK
I need to achieve multiple producer and one consumer problem. The restriction is i
Share
Create two blocking queues – one for each producer. The consumer knows about both queues, and tries to take an element from each of them. (It can do that just by taking from one then the other.) When it’s got an element from each, it processes it, then repeats.
You’ll need to consider what you want to happen if one producer is much faster than another though – you probably want the queues to be bounded, and work out what to do if one producer “fills” its queue.