File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes why wait notify notifyall defined in object class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "why wait notify notifyall defined in object class" Watch "why wait notify notifyall defined in object class" New topic
Author

why wait notify notifyall defined in object class

saikrishna cinux
Ranch Hand

Joined: Apr 16, 2005
Posts: 689
hi,

why these 3 methods wait() notify() notifyall methods are declared in Object class?

these methods are already implemented in Thread class?


any best answer???



thanks in advance


A = HARDWORK B = LUCK/FATE If C=(A+B) then C=SUCCESSFUL IN LIFE else C=FAILURE IN LIFE
SCJP 1.4
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14114
    
  16

these methods are already implemented in Thread class?

No, they are not implemented in class Thread. Class Thread extends Object and so it inherits the methods from class Object.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
Srikanth Basa
Ranch Hand

Joined: Jun 06, 2005
Posts: 241
Originally posted by saikrishna cinux:
hi,

why these 3 methods wait() notify() notifyall methods are declared in Object class?

these methods are already implemented in Thread class?


any best answer???



thanks in advance


You did not get the essence of "Object" locking

Go through the API carefully and I hope that should help
http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Object.html#wait()
saikrishna cinux
Ranch Hand

Joined: Apr 16, 2005
Posts: 689
Originally posted by Srikanth Basavaraju:


You did not get the essence of "Object" locking

Go through the API carefully and I hope that should help
http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Object.html#wait()


what do you mean by essence of object locking my dear friend???

any way please tell me why they have imlemented these methods in object class and then overrided in Thread class?

what is the use of implementing these methods in object class only why not in any other class???
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18760
    
  40

any way please tell me why they have imlemented these methods in object class and then overrided in Thread class?


It wasn't "overridden" in the Thread class.


what is the use of implementing these methods in object class only why not in any other class???


They implemented in the Object class because they wanted every object to be useable as a notification object. Whether or not you agree that this is a good idea is another issue.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Srikanth Basa
Ranch Hand

Joined: Jun 06, 2005
Posts: 241
Aha ! I'm sure you will have to go through the whole story on
Threads
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: why wait notify notifyall defined in object class