CSE Roadmap

Core tier · about 3 hours · 6 parts

Part 1 of 6 · 1 min read

Why this page comes fourth in Level 5

In this module you will

  • Explain the producer-consumer pattern and the role of a bounded blocking queue.
  • Write a producer and a consumer with BlockingQueue, and shut the consumer down cleanly.
  • Use an ExecutorService instead of creating threads by hand.
  • Read results and failures through Future.
  • Explain pool size, queue size and the choice of what to do when the queue is full.

Module 3 showed how to protect shared data. This page shows how to avoid sharing it by passing work through a queue. Notification systems, order processing, loggers and job schedulers in LLD rounds all use this shape. The sources are "Java Concurrency in Practice" (JCIP) chapters 5, 6, 7 and 8, and "Effective Java" (EJ) Items 80 and 81. Code was compiled and run before it was written here. Numbers marked "made up" only show the idea.