{
  "id": 14686815,
  "title": "Concurrency Programming (10): How BlockingQueue and Channels Work — From Runtime to CPU",
  "url": "https://urgent.news/2026/10/15/concurrency-programming-10-how-blockingqueue-and-channels-work-from",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-10-15T11:57:11.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/thinkerqaq/concurrency-programming-10-how-blockingqueue-and-channels-work-from-runtime-to-cpu-34lm"
  },
  "original_language": "en",
  "account": "The article compares the implementations of BlockingQueue, channels, and queue.Queue in Java, Go, and CPython. These data structures provide guarantees around Atomicity, Visibility, and Ordering across different layers of the runtime, standard libraries, and hardware.\n\nAt the language/library layer:\nIn Java, the ArrayBlockingQueue uses a lock (ReentrantLock) for atomicity, ensuring one enqueue or dequeue operation updates the queue state without interference from other threads. Visibility and ordering are maintained through the lock, making the producer's writes visible to the consumer once the lock is acquired.\n\nIn Go, channels achieve atomicity by acquiring a lock (chanlock) before updating buffer state or finding a waiting peer. Visibility is ensured by the lock's order, with writes taking effect before reads. Ordering is provided through acquire/release semantics and memory ordering constraints on the x86-64 hardware.\n\nAt the hardware layer:\nAtomicity is achieved through atomic instructions like LOCK CMPXCHG, which update shared data without interference. Visibility relies on cache coherence protocols (MESIF or MOESI) to ensure updates are propagated to all caches. Ordering is managed by acquire and release memory fences, ensuring the correct sequence of read-modify-write operations.\n\nIn summary, all three implementations rely on a combination of locks, atomic instructions, cache coherence, and memory ordering to provide consistent guarantees across the runtime, standard library code, and hardware. These primitives enable thread-safe communication and synchronization, even in the presence of concurrent access.",
  "summary": "Table of Contents 0. What Does This Article Answer Next? 1. How Does the JDK Implement ArrayBlockingQueue? 1.1 Layers 1.2 End-to-End Implementation Path for put / take 1.3 Guarantees at the Runtime / Language Implementation Layer 1.3.1 Atomicity 1.3.2 Visibility and Ordering 1.4 Guarantees at the Hardware Layer 2. How Does Go Runtime Implement Channels? 2.1 Layers 2.2 End-to-End Implementation…",
  "key_points": [
    "Java's ArrayBlockingQueue uses ReentrantLock for atomicity",
    "Go's channels achieve atomicity via lock (chanlock)",
    "Hardware layer ensures visibility and ordering through cache coherence and memory fences"
  ],
  "editors_take": null,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}