• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Doubt regarding wait(), notify() and notifyAll() methods

 
Mansukhdeep Thind
Ranch Hand
Posts: 1158
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All
Please tell me one thing. If the methods wait(), notify() and notifyAll() are used in context of mulithreading, then why are these methods of java.lang.Object class and not java.lang.Thread class?

Regards
Mansukhdeep
 
pete stein
Bartender
Posts: 1561
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is a very good question; so good that it has been asked many many times. A simple search of this forum will likely bring you many decent replies to similar questions. For instance this one: Why-java-lang-Object

Much luck!
 
Shanky Sohar
Ranch Hand
Posts: 1051
Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
because before calling any of these method we have to synchronized it with a object.

we have to occupy a lock on a object monitor
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic