The Producer Consumer Pattern is a work load distribution pattern where the number of worker threads is decoupled from the number of tasks they have to execute. In this video I explain how the producer consumer pattern works in multithreading. You can also implement the producer consumer pattern with processes (instead of threads), but since this video is part of a playlist about Java Concurrency, I will focus on how the producer consumer pattern looks for threads.
Chapters:
0:00 Producer consumer pattern introduction
4:01 Producer consumer pattern use cases
4:24 Reduce foreground thread latency - GUI app
7:21 Reduce foreground thread latency - server
9:50 Load balance between worker threads - recap
10:40 Backpressure management
13:50 Producer consumer Java code example
The Producer Consumer Pattern - text:
http://tutorials.jenkov.com/java-concurrency/producer-consumer.html
Java BlockingQueue - text / video:
http://tutorials.jenkov.com/java-util-concurrent/blockingqueue.html
https://www.youtube.com/watch?v=d3xb1Nj88pw&list=PLL8woMHwr36EDxjUoCzboZjedsnhLP1j4&index=17
Java Concurrency - text / video playlist:
http://tutorials.jenkov.com/java-concurrency/index.html
https://www.youtube.com/playlist?list=PLL8woMHwr36EDxjUoCzboZjedsnhLP1j4