A bounded buffer is a classic synchronization problem in concurrent programming. It's a fixed-size buffer that:
- Allows producers to add items
- Allows consumers to remove items
- Blocks producers when the buffer is full
- Blocks consumers when the buffer is empty
This pattern is fundamental to many real-world applications like message queues, I/O buffering, and thread pools.
You must implement the BoundedBuffer class that provides thread-safe operations for multiple producers and consumers.
- Clone the repository
- Implement the methods in src/main/java/BoundedBuffer.java
- Test locally:
./mvnw test - Run the demo:
./mvnw exec:java - Commit and push to trigger autograding
# Run tests
./mvnw test
# Run the demo program
./mvnw exec:java
# Clean build
./mvnw clean test