Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Threads and Synchronization and the fly likes Threads Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark "Threads" Watch "Threads" New topic
Author

Threads

Ajnam Bujanany
Greenhorn

Joined: Jan 27, 2005
Posts: 3
Why notify(),notifyAll() and wait() methods are in Object class and not in Thread Class?
Peter Chase
Ranch Hand

Joined: Oct 30, 2001
Posts: 1970
A quick answer might be that wait() and notify() are used to control behaviour of a particular object, which interacts with more than one thread.

A Thread does, of course, have these methods, as it inherits from Object. However, it is rarely, if ever, useful to use wait() and notify() on a Thread.

Look at some typical examples of how wait() and notify() are used, and then think how you'd implement them if wait() and notify() were methods on Thread not Object. Chances are, it would be harder or impossible to achieve the same functionality.


Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Threads
 
Similar Threads
Doubt about diagram class (realization)
WA #1.....word association
can non-static inner class access any member
andrew has wii
Doubt about diagram class