This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Why Wait() ,notify(),notifyAll() in Object class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Why Wait() ,notify(),notifyAll() in Object class" Watch "Why Wait() ,notify(),notifyAll() in Object class" New topic
Author

Why Wait() ,notify(),notifyAll() in Object class

Mintoo kumar
Ranch Hand

Joined: Aug 21, 2007
Posts: 61
Folks,

I know it's basic level questaion to ask.

I have doubt is why these there methods wait(),notify(),notifyAll() is in object class?
After so much digging i came up with some solution ->

1. JAVA is root heirarchy language and every ojbect has some internal thread run( like garbage collection thread).So if we put it in Thread then we have to inherit and unnecessariy take overhead of other facility of Thread class.
2.except waiting on thread ,there is condition where we need to wait on database then putting these methods in thread restrict us to inherit thread ,which is not required.
Like this there are couple of more reason. i found.

I just wanted to know the above reason i mentioned is what extent correct . if it is not then what are the reasons?

Thanks in advance.
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

Hi,

i am not sure about your idea...but commonly
----------------------------------------------------------
these methods are used to communicate between the threads

-----------------------------------------------------------

thanks & regards,
seetharaman.v
Mintoo kumar
Ranch Hand

Joined: Aug 21, 2007
Posts: 61
Thanks for your response.

But if it is used for communication b/w thread then why not in thread class? why it is in Object class , does it make sense?
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Using the search feature of this side, I found this in the FAQ: http://faq.javaranch.com/java/WaitAndNotifyInObjectClass

There were also quite some hits for messages in this forum.


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38040
    
  22
Originally posted by Ilja Preuss:
Using the search feature of this side, I found this in the FAQ: http://faq.javaranch.com/java/WaitAndNotifyInObjectClass

There were also quite some hits for messages in this forum.

Like here, here, and here.
Mintoo kumar
Ranch Hand

Joined: Aug 21, 2007
Posts: 61
Thanks both of you.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38040
    
  22
You're welcome. Hope that sorted out your problem.
 
jQuery in Action, 2nd edition
 
subject: Why Wait() ,notify(),notifyAll() in Object class
 
Similar Threads
Interview q
Thread Specific methods why in Object class ?
Threads
Methods in Object Class
Object class doubt