GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Interview Questions  >  J2EE  >  EJB
Go To First  |  Previous Question  |  
 EJB  |  Question 175 of 175    Print  
wait(), notify() and notyfyAll() methods
Why wait(), notify() and notyfyAll() methods are avialble in Object class but not in Thread class? Explain.


  
Total Answers and Comments: 5 Last Update: September 12, 2009     Asked by: varalakshmi.k 
  
 Sponsored Links

 
 Best Rated Answer
Submitted by: lks007
 

As wait(), notify() and notyfyAll() methods are present in Object class which is a super class for all the classes. There is no need to redefine the same methods in other classes as they all will inherit them from there super class Object.



Above answer was rated as good by the following members:
hcse04, geeky920
August 20, 2008 04:12:02   #1  
question2answer Member Since: August 2008   Contribution: 1    

RE: wait(), notify() and notyfyAll() methods
All three methods are used with Threading mechanism.

Thanks

 
Is this answer useful? Yes | NoAnswer is useful 1   Answer is not useful 1Overall Rating: -N/A-    
August 22, 2008 05:11:54   #2  
lks007 Member Since: August 2008   Contribution: 1    

RE: wait(), notify() and notyfyAll() methods

As wait() notify() and notyfyAll() methods are present in Object class which is a super class for all the classes. There is no need to redefine the same methods in other classes as they all will inherit them from there super class Object.


 
Is this answer useful? Yes | NoAnswer is useful 1   Answer is not useful 2Overall Rating: -1    
August 22, 2008 07:54:47   #3  
Karuna Reddy Member Since: June 2007   Contribution: 40    

RE: wait(), notify() and notyfyAll() methods

wait() notify() and notyfyAll() methods these are inherited from Object class.
if you call wait() method it will enter in to the monitor for specfic time or ideal time when call notify() it will enter from the waiting pool to ready state
When notifyAll() calls then it will bring all of the waiting threads from waiting pool to ready state


 
Is this answer useful? Yes | NoAnswer is useful 1   Answer is not useful 1Overall Rating: -N/A-    
September 25, 2008 00:02:19   #4  
janswain Member Since: September 2008   Contribution: 1    

RE: wait(), notify() and notyfyAll() methods

Each object in java is associated with a lock and the wait and notify methods are not associated with a thread but with a lock so coupling locks and objects meant that each object should have wait and notify methods that operate on that object s lock.

Java provides a way to lock the code for a thread which is currently executing it using the synchorinized keyword and making other threads that wish to use it wait until the first thread is finished.These other threads are placed in the waiting state .Once the first thread completes it task than it notifies others in the queue by giving the lock to JVM.Now JVM decides which thread will exceute next by its internal algo.Hence the wait and notify methods has to be in Object class as it acquires lock and has to notify others.....


 
Is this answer useful? Yes | NoAnswer is useful 2   Answer is not useful 0Overall Rating: +2    
September 12, 2009 03:56:50   #5  
pandeysc99 Member Since: September 2009   Contribution: 1    

RE: wait(), notify() and notyfyAll() methods
All the common and system security method is defined in Object class and wait notify notrifyAll is related with system and process security so they are defined in object class in spite of Thread class;
 
Is this answer useful? Yes | No


 
Go To Top


 Sponsored Links

 
About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape