Producer and consumer with an unbounded buffer
Try it yourself
Make the producer faster than the consumer and watch the buffer grow. Then flip them and see who waits.
Trace the code
The arrow keys and the space bar control the section you clicked last.