Producer Consumer Pattern
807605Jul 13 2007 — edited Jul 13 2007I 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??