File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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 REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark "Threads" Watch "Threads" New topic


Ajnam Bujanany

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.
Don't get me started about those stupid light bulbs.
subject: Threads
It's not a secret anymore!