0

I have a relationship that must work as follows; thread A publishes some change to thread B, who takes that change and publishes it to thread C.

The problem is producer-consumer, and I have no problem using a BlockingQueue to implement it with only two entities. How can I make thread B a sort of hybrid producer and consumer to make this work? As in, is there some specified model to follow for problems in this genre?

aquemini
  • 950
  • 2
  • 13
  • 32

1 Answers1

2

Use two blocking queues: one between A and B; the other between B and C.

Ted Hopp
  • 232,168
  • 48
  • 399
  • 521
  • So, I should pass in two BlockingQueues into the constructor of B? – aquemini Feb 24 '13 at 17:26
  • @CoconutJones - How you set it up depends on how your surrounding code is structured. It might set up by an external code and passed to the constructors for B (and C), or set up by B in its constructor, or by C. The only requirement is that the second queue is set up in such a way that B and C can both access it. Without seeing your code, it's hard to make any recommendation. – Ted Hopp Feb 24 '13 at 18:15