Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

why wait notify notifyall defined in object class

 
saikrishna cinux
Ranch Hand
Posts: 689
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15203
36
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Srikanth Basa
Ranch Hand
Posts: 241
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 689
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Marshal
Pie
Posts: 20880
75
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Srikanth Basa
Ranch Hand
Posts: 241
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Aha ! I'm sure you will have to go through the whole story on
Threads
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic