producer-consumer problem

a number of threads are producing some elements and placing em in the queue, and some threads are eating (consuming them). All works fine, except that i now want to add a feature to it. I want to get the maximum no of elements present in the queue at any time during the whole process. I have thought of two possibilities

1. when i am adding elements to the queue (surely protected by mutex) i get the queue length and compare to max.

2. when i am consuming elements just before consuming (popping) i get the length.

according to me both should be ok. am i right ?? plz suggest smthing to make it more accurate.

Either one will work.

I personally would go with #1, since it is adding to the queue that increases the maximum, not removing.
zee thanx :D, do u have any other ideas that u can share ??
Topic archived. No new replies allowed.