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

Explain the stub's and skeleton's functionality?

7 Answers  


diffrence between jsp and servelts.

6 Answers  


How messaging services are done, before release of JMS?

0 Answers  


Describe activation process?

0 Answers  


what about static?

1 Answers  


On a computer that having single CPU, how multithreading concept can be achieved?

1 Answers   Zensar,


Will the general public have access to the infobus apis?

0 Answers  


Explain the methods of Naming class, rebind( ) and lookup()?

1 Answers  


What is the name of the state, when a thread is executing?

4 Answers  


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

1 Answers  


What is Connection Pooling?

1 Answers   Enteg Technologies, Infosys, Polaris,


When a thread terminates its processing, it enters into what state?

1 Answers  


Categories