Producer and consumer with a bounded buffer
Try it yourself
Make the producer faster than the consumer, then the other way around. Watch who ends up waiting, and try different sizes.
Trace the code
The arrow keys and the space bar control the section you clicked last.