Two BlockingQueue in the same endless loop?

Posted by DrDol on Stack Overflow See other posts from Stack Overflow or by DrDol
Published on 2010-04-02T23:23:22Z Indexed on 2010/04/02 23:33 UTC
Read the original article Hit count: 267

Filed under:
|
|

I have a thread, that processes incomming messages (endless loop). For this, I use a BlockingQueue (Java), which works as quite nice. Now, I want to add a second processor in the same Class oder method. The problem now is, that in the endless loop i have this part

newIncomming = this.incommingProcessing.take();

This part blocks if the Queue is empty. I'm looking for a solution to process to queues in the same class. The second queue can only processed, it some data is coming in for the first Queue. Is there a way to handle tow blocking queues in the same endless loop?

© Stack Overflow or respective owner

Related posts about java

Related posts about queue