Java Threads Question:

Download Job Interview Questions and Answers PDF

Which class is the wait() method defined in?

Java Threads Interview Question
Java Threads Interview Question

Answer:

The wait() method is defined in the Object class, which is the ultimate superclass of all others. So the Thread class and any Runnable implementation inherit this method from Object. The wait() method is normally called on an object in a multi-threaded program to allow other threads to run. The method should should only be called by a thread that has ownership of the object's monitor, which usually means it is in a synchronized method or statement block.

Download Java Threads Interview Questions And Answers PDF

Previous QuestionNext Question
What is the volatile modifier for?What is a green thread?