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

wait and notify method method

deepak carter
Ranch Hand

Joined: Feb 19, 2011
Posts: 165
wait and notify notifyall method are basically used are basically used in threads so why they are included in Object class and not in thread class
Matthew Brown
Bartender

Joined: Apr 06, 2010
Posts: 4363
    
    8

Threads synchronize on objects, and those methods are related to the object you're synchronizing on, not the thread that's doing the synchronizing.
deepak carter
Ranch Hand

Joined: Feb 19, 2011
Posts: 165
sir can you please example in details
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18707
    
  40

deepak carter wrote:wait and notify notifyall method are basically used are basically used in threads so why they are included in Object class and not in thread class


deepak carter wrote:sir can you please example in details



Please do a search for this (SearchFirst), as this question comes up often....

http://www.coderanch.com/t/233340/threads/java/Why-java-lang-Object

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Jeff Verdegan
Bartender

Joined: Jan 03, 2004
Posts: 6109
    
    6

deepak carter wrote:wait and notify notifyall method are basically used are basically used in threads so why they are included in Object class and not in thread class


Because wait() and notify() apply to locks and every object has a lock.

Also, everything in Java is "used in threads."
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: wait and notify method method