1.

Which of these method is used to tell the calling thread to give up a monitor and go to sleep until some other thread enters the same monitor?(a) wait()(b) notify()(c) notifyAll()(d) sleep()I had been asked this question in quiz.My query is from Creating Threads topic in division Multithreading of Java

Answer»

Correct option is (a) WAIT()

The best I can explain: wait() method is used to tell the calling thread to GIVE up a MONITOR and go to sleep until some other thread enters the same monitor. This HELPS in avoiding polling and MINIMIZES CPU idle time.



Discussion

No Comment Found

Related InterviewSolutions