If you remember to release the lock before exiting producer's run(), the consumer should be able to continue, just be sure to set some flag in the producer so that the consumer exits instead of trying to aquire the lock again. This way it should also work with semaphores.

Of course it is easier to use a wait condition like Jacek suggested, but you'll still need to flag the consumer so that it exits before aquiring the lock again. Using wait conditions won't really change much here (I guess it would be more usefull if you had more consumers), but it'll look nicer

In both cases you have to set the flag before the producer releases the mutex/semaphore! Otherwise the consumer might jump into the critical section once (or more times) too many.