Hello all,

i've got a problem can't resolve it, hope someone can help.
In few words i have a shared buffer, where both producer and consumer, put
and retreive items.
now say i have 4 producer thread producing 5 items each, and 3 consumer taking
those items out of the buffer.
now the prob is i don't know how to tell the consumer to stop retrieving
these items when all producer are done, it just waits forever.
bare in mind that comsumer doesn't know how many item are produced by the
procucer threads, the only thing they have in common, is the buffer.
i have tried few methods( i.e check wehn the buffer is empty, but this is
no working, coz it turns out to be true when a consumer takes the item as
soon as it's been produce) or is there a way i can put some sort of flag
in the buffer to say that the last has been retreived.

hope it makes sense,i'm just too confuse myself,