Answers

Question and Answer:

  Home  Java Classes

⟩ What is the significance of wait() method with respect to Object class, not in Thread class?

the wait() method is defined in the java.lang.OBject() class and not in the java.lang.Thread()class. it's signature is public static void wait(). we do have some overloaded versions of the wait() method. when an wait method is called by an thread on a object it release the lock on the object and goes to an WAIT/BLOCKED state inorder to let the other threads to enter the RUNNING state. However it regains the Lock on the object after sometime when it moves from the WAIT/BLOCKED state to RUNNABLE state . that can happen due to the call of notify(),notifyAll() methods by other threads holding of the respective objects Lock.

 135 views

More Questions for you: