For the problem of the consumer-producer there are many solutions, with the condition that the buffer where unbounded we reach to the next one.
function main
function producer
function consumer
How this algorithm will solve the problem?
Well in this solution the producer is free to create items at any time, the cosumer doesn't care at all.
But if the consumer want to take an item, he need to check the amount of items in stock, if the amount is zero, he will do nothing.