producer / consumer question
my consumer waits for a producer putting things in a vector as in the pseudo code below:
I guess I got something wrong regarding the concept of producer/consumer. how can I avoid the problem mentioned in the comment above?
// ok, the condition was signaled by the producer
// the producer can now put new things in
// and they are going to be proper handled because of the while-loop
while(vector != empty)
// now this place is interesting:
// the while loop is ended so all things are consumed
// but exactly at this point a new thing is produced and put in the vector
// and the condition is signaled
// but the consumer does not wait yet
// so I guess the consumer is starving until a second thing is produced
Thank you in advance!