Using the given stub class (ProducerConsumerTemplate.java
), implement a simple blocking
producer/consumer pattern with the following behaviors and characteristics:
- A producer thread that enqueues random integers to its shared queue
- A consumer thread that consumes and prints integers from the queue to standard out
- A fully thread-safe, blocking queue mechanism shared between the producer and consumer threads
- Absolutely no use of the
java.util.concurrent
package - You may modify the original source as desired to improve the overall design. Be prepared to explain your improvements.
- Implement a solution to Question 1A again. You are permitted to use
java.util.concurrent
.
- JDK 11
- maven 3
I used google code style format - intellij-java-google-style.xml
. Settings -> Code style -> Scheme
-> Import scheme.
https://github.com/google/styleguide/blob/gh-pages/intellij-java-google-style.xml
- You need java 11. You need maven 3
- Build with maven
mvn clean package
- Run the app in the console
java -jar ./target/producer-consumer-pattern-challenge-jar-with-dependencies.jar