Why wait, notify, notifyall methods are defined in Object class?

Showing Answers 1 - 2 of 2 Answers

sbarik

  • Jun 20th, 2006
 

Every Object has a monitor associated with it.Now threads using that object can lock or unlock the monitor associated with the object.Wait and notify methods deal with aquiring and relinquishing the lock associated with the pericular object.

Calling wait causes the current thread to wait to aquire the lock of the Object

And invocation of notify causes the current thread to notify another thread that is waiting to aquire the lock of the Object.

Thats why these methods are in Object class.

  Was this answer useful?  Yes

umesh choubey

  • Jan 17th, 2007
 

when our class is loaded in the memery.in that time firsty the java.lang.Class class object created in the Heap.

 if in the heap java.lang.Class class object is created that means that class is loaded in the memeory.otherwise is not loaded .

so in the multithreading when we get the monitor on that object that means we got the control on that the object .means we got the control on that object that is generick functionality of any object ,we got lock on the object means on the java.lang.Class object that why theses method is define in java.lang.object class

umesh choubey   

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions