What happens when wait() & notify() method are called

Carvia Tech | December 04, 2019 | 1 min read | 2 views


wait() and notify() methods are called for inter thread communication on a shared object.

wait() method

When wait() method is invoked from a synchronized context, the following things happen

  1. The calling thread gives up the lock.

  2. The calling thread gives up the CPU.

  3. The calling thread goes to the monitor’s waiting pool.

notify() method

And in case of notify() method, following things happen

  1. One of the waiting thread (may be a random thread) moves out of the monitor’s waiting pool.

  2. Thread comes into ready state (RUNNABLE).

  3. Tries its best to require the monitor lock before it can proceed to the method execution.


Top articles in this category:
  1. What is difference between sleep() and wait() method in Java?
  2. Can two threads call two different synchronized instance methods of an Object?
  3. What will happen if we don't synchronize getters/accessors of a shared mutable object in multi-threaded applications
  4. What is difference between JDK JRE and JVM
  5. What is difference between Callable and Runnable Interface?
  6. What is Immutable Class in Java
  7. What is difference between ExecutorService submit and execute method


Find more on this topic:
Core Java image
Core Java

Core Java - OOP Concepts, Garbage Collection, Multi-threading, Collections Framework, Java 8 Features, Lambda Functions, Streams.

Last updated 1 week ago


Recommended books for interview preparation:

This website uses cookies to ensure you get the best experience on our website. more info