Tag

wait-notify

0 views collected around this technical thread.

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.

CompletableFutureConcurrencyJava
0 likes · 9 min read
Replacing Thread.sleep Loops with Proper Scheduling in Java
Selected Java Interview Questions
Selected Java Interview Questions
Sep 17, 2022 · Backend Development

Converting Asynchronous Calls to Synchronous in Java: Five Common Techniques

This article explains how to turn Java asynchronous invocations into synchronous ones by demonstrating five approaches—wait/notify, condition locks, Future, CountDownLatch, and CyclicBarrier—each illustrated with complete code examples and detailed execution flow.

CountDownLatchCyclicBarrierFuture
0 likes · 11 min read
Converting Asynchronous Calls to Synchronous in Java: Five Common Techniques
Cognitive Technology Team
Cognitive Technology Team
May 5, 2022 · Fundamentals

Java Thread Communication: Implementation of wait(), notify() and notifyAll()

This article explains how Java's wait(), notify() and notifyAll() methods work for inter‑thread communication, covering the required synchronized context, lock release behavior, wake‑up conditions, the importance of using while loops to avoid spurious wake‑ups, and provides a concise code example.

ConcurrencyJavaSynchronization
0 likes · 4 min read
Java Thread Communication: Implementation of wait(), notify() and notifyAll()
Selected Java Interview Questions
Selected Java Interview Questions
Oct 20, 2021 · Fundamentals

Why wait() Must Be Used Inside a while Loop Instead of if in Java Synchronization

This article explains why the wait() method in Java synchronized blocks must be placed inside a while loop rather than an if statement, illustrating the issue with concurrent producers and consumers through code examples and detailing when to use notifyAll versus notify.

ConcurrencyJavaSynchronization
0 likes · 8 min read
Why wait() Must Be Used Inside a while Loop Instead of if in Java Synchronization
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.

ConcurrencyConditionJava
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.

ConcurrencyJavamultithreading
0 likes · 9 min read
Producer-Consumer Problem and wait()/notify() in Java
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.

ConcurrencySynchronizationThread
0 likes · 15 min read
Understanding Java Thread States and Synchronization Methods: wait/notify, sleep/yield, and join
Selected Java Interview Questions
Selected Java Interview Questions
Dec 14, 2019 · Backend Development

Java Thread Communication Methods: Synchronized, Polling, wait/notify, and Piped Streams

This article explains four common Java thread communication techniques—synchronized blocks, while‑polling, wait/notify, and piped streams—providing code examples and discussing their advantages, drawbacks, and practical usage in multithreaded applications.

JavaPiped StreamsSynchronization
0 likes · 10 min read
Java Thread Communication Methods: Synchronized, Polling, wait/notify, and Piped Streams
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.

ConcurrencyJavaThread Synchronization
0 likes · 9 min read
Java Producer‑Consumer Example with Multiple Threads and Synchronization Improvements
Ctrip Technology
Ctrip Technology
Nov 22, 2016 · Backend Development

Understanding Java Object.wait() and notify() Implementation in the HotSpot JVM

This article explains the internal workings of Java's Object.wait() and notify() methods, detailing how synchronized blocks, monitorenter/monitorexit instructions, the HotSpot ObjectMonitor, wait sets, and entry lists cooperate to manage thread coordination and lock ownership in multithreaded environments.

ConcurrencyHotSpotJVM
0 likes · 10 min read
Understanding Java Object.wait() and notify() Implementation in the HotSpot JVM