Tagged articles
17 articles
Page 1 of 1
The Dominant Programmer
The Dominant Programmer
Jul 9, 2025 · Fundamentals

Mastering Java Thread Communication: volatile, synchronized, wait/notify, and Piped Streams

This article explains how Java threads interact using volatile for visibility, synchronized blocks for mutual exclusion, wait/notify (and Condition) for coordination, piped streams for one‑way byte communication, as well as Thread.join and ThreadLocal utilities, providing concrete code examples, best‑practice guidelines, and performance considerations.

JavaPipedStreamThreadLocal
0 likes · 23 min read
Mastering Java Thread Communication: volatile, synchronized, wait/notify, and Piped Streams
Xuanwu Backend Tech Stack
Xuanwu Backend Tech Stack
Jan 9, 2025 · Fundamentals

Master Java Thread Communication: wait/notify, Locks, Conditions & BlockingQueue

This article explores Java's thread communication techniques—including the basic wait/notify mechanism, advanced Lock and Condition usage, and the thread‑safe BlockingQueue—providing detailed explanations, producer‑consumer examples, and additional concurrency utilities like CountDownLatch, illustrating how to coordinate threads efficiently in multithreaded applications.

BlockingQueueConditionCountDownLatch
0 likes · 18 min read
Master Java Thread Communication: wait/notify, Locks, Conditions & BlockingQueue
IT Services Circle
IT Services Circle
Jan 7, 2025 · Backend Development

Replacing Thread.sleep Loops with Proper Scheduling in Java

The article explains why using Thread.sleep in a loop causes busy‑waiting and performance problems, and demonstrates several Java scheduling alternatives—including Timer/TimerTask, ScheduledExecutorService, wait/notify, and CompletableFuture—to efficiently check a flag at fixed intervals.

CompletableFutureJavaScheduledExecutorService
0 likes · 9 min read
Replacing Thread.sleep Loops with Proper Scheduling in Java
Architect
Architect
Aug 16, 2023 · Backend Development

5 Practical Ways to Implement Thread Communication in Java

This article compares five Java thread‑communication techniques—volatile flag, Object.wait()/notify(), CountDownLatch, ReentrantLock with Condition, and LockSupport—by presenting concrete code examples, explaining their underlying mechanisms, and discussing their advantages and drawbacks.

CountDownLatchJavaLockSupport
0 likes · 13 min read
5 Practical Ways to Implement Thread Communication in Java
Full-Stack Internet Architecture
Full-Stack Internet Architecture
Dec 16, 2020 · Backend Development

Using Condition to Replace wait/notify for Safer and Faster Java Thread Communication

This article explains why Java's Condition class should replace wait/notify for thread communication, demonstrates the thread‑livelock problem with notify, shows how Condition avoids it, compares performance with notifyAll, and provides complete code examples for producer‑consumer scenarios.

ConditionJavaThread Communication
0 likes · 13 min read
Using Condition to Replace wait/notify for Safer and Faster Java Thread Communication
Full-Stack Internet Architecture
Full-Stack Internet Architecture
Oct 1, 2020 · Fundamentals

Producer-Consumer Problem and wait()/notify() in Java

This article explains the classic producer‑consumer concurrency model, its advantages of decoupling, asynchrony and speed balancing, and demonstrates how Java’s wait(), notify() and notifyAll() mechanisms are used to coordinate producer and consumer threads with sample code implementations.

JavaProducer Consumerwait/notify
0 likes · 9 min read
Producer-Consumer Problem and wait()/notify() in Java
Java Backend Technology
Java Backend Technology
Jun 27, 2020 · Fundamentals

Why Use a while Loop Instead of if with wait() in Java Synchronization?

This article explains why a while loop is required rather than an if statement when using wait() inside synchronized blocks, demonstrates the race condition with a bounded buffer example, shows the correct fix, discusses notifyAll versus notify, and illustrates how improper use can lead to deadlocks in Java multithreading.

Javaconcurrencymultithreading
0 likes · 8 min read
Why Use a while Loop Instead of if with wait() in Java Synchronization?
Selected Java Interview Questions
Selected Java Interview Questions
Mar 30, 2020 · Backend Development

Understanding Java Thread States and Synchronization Methods: wait/notify, sleep/yield, and join

This article explains Java thread lifecycle states, demonstrates how to use wait, notify, and notifyAll for inter‑thread coordination, compares sleep, yield, and join methods with practical code examples, and highlights important considerations such as monitor ownership and thread scheduling.

Synchronizationsleepwait/notify
0 likes · 15 min read
Understanding Java Thread States and Synchronization Methods: wait/notify, sleep/yield, and join
Programmer DD
Programmer DD
Mar 21, 2020 · Fundamentals

Why Does Concurrent Programming Need Wait/Notify? Unlock Efficient Thread Coordination

This article explains why busy‑waiting loops waste CPU in Java concurrency, introduces the wait/notify mechanism, shows how synchronized, wait() and notify()/notifyAll() work together, highlights common pitfalls such as using if instead of while, and provides practical code examples and best‑practice guidelines for safe thread coordination.

JavaMESA ModelSynchronization
0 likes · 14 min read
Why Does Concurrent Programming Need Wait/Notify? Unlock Efficient Thread Coordination
Programmer DD
Programmer DD
Dec 4, 2019 · Fundamentals

What a Fruit Store Can Teach You About Java Concurrency

This article uses a vivid fruit‑store analogy to explain Java multithreading concepts such as locks, synchronized blocks, wait/notify, thread states, time‑slicing, and volatile variables, helping readers grasp core concurrency mechanisms in an engaging narrative.

LocksSynchronizationconcurrency
0 likes · 18 min read
What a Fruit Store Can Teach You About Java Concurrency
Java Backend Technology
Java Backend Technology
Oct 10, 2017 · Fundamentals

Mastering Java Thread Communication: Wait/Notify Explained with Real Code

This article introduces Java's wait/notify thread communication mechanism, explains its principles with analogies, details the behavior of wait and notify methods, provides step‑by‑step code examples—including a simple producer‑consumer queue—and highlights important considerations such as lock handling and thread states.

JavaThread Communicationconcurrency
0 likes · 9 min read
Mastering Java Thread Communication: Wait/Notify Explained with Real Code
Java Captain
Java Captain
Dec 7, 2016 · Fundamentals

Java Producer‑Consumer Example with Multiple Threads and Synchronization Improvements

This article explains the classic producer‑consumer problem in Java, demonstrates initial implementations using wait/notify with a single producer and consumer, analyzes issues that arise with multiple threads, and presents step‑by‑step code refinements—including while‑loops and notifyAll—to achieve correct multithreaded synchronization.

Producer ConsumernotifyAllthread synchronization
0 likes · 9 min read
Java Producer‑Consumer Example with Multiple Threads and Synchronization Improvements