Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Producer Consumer Pattern

807605Jul 13 2007 — edited Jul 13 2007
I am using a BlockingQueue (LinkedBlockingQueue implementation) with multiple consumers consuming objects that I take from the queue.

I want to take the records from the queue and add them to a set. I want to maintain a counter of the number of records I add to the set and another counter for the size of the set.

When I do a size on the set it gives me a different figure from the count I am using when I put records into the set!!

How do I maintain a reliable counter in this produce consume pattern. At what point is it valid to display the consumed records??
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 10 2007
Added on Jul 13 2007
3 comments
146 views