Explain the purposes of methods wait(), notify(), notifyAll
()?

Answers were Sorted based on User's Feedback



Explain the purposes of methods wait(), notify(), notifyAll ()?..

Answer / tek

All the three methods are called in synchronized block or
method.

wait(): Thread calling wait method will go to the waiting
state and it will loose its monitor. It will execute only
if it is notified by the other threads.

notify(): To notify thread which is waiting for the concern
object.

notifyAll(): To notify all the threads which are in waiting
state.

Is This Answer Correct ?    2 Yes 0 No

Explain the purposes of methods wait(), notify(), notifyAll ()?..

Answer / sumitpalsingh

The purpose of using the wait(),notify() and notifyAll() methd is used for interThread communication.
for Example :-There is a n situation communication between Producer and Consumer...Producer wll produce an item and go to waiting state by using wait() method.and it will notify to the consumer for to consume an item. After conume an Item Consumer will come into waiting state by using wait() method ..and give the notification to Produer by using notify() method to produce an item.But all these methods are called only in synhronized() method or synchronized block.

Is This Answer Correct ?    1 Yes 0 No

Post New Answer

More Advanced Java Interview Questions

whats is mean by class.forName() whats the return type of class

6 Answers   SolutionNET,


what is an isolation level?

0 Answers  


Is it possible to stop the execution of a method before completion in a sessionbean?

0 Answers  


How are commas used in the intialization and iteration parts of a for statement?

0 Answers  


How to deploy Jar, War files in J2EE?

0 Answers   HCL,






how i secure my site with the https protocol.what are the steps?

0 Answers  


what do u mean by java bean??

2 Answers   ADP,


What is the argument type of a programs main() method?

0 Answers  


Define prototype?

0 Answers  


Are enterprise beans allowed to use thread.sleep()?

0 Answers  


How many ways can a thread be used?

4 Answers   Sun Microsystems,


What are the types of data passing mechanisams under JMS specification?

1 Answers  


Categories