| Author |
wait and notify method method
|
deepak carter
Ranch Hand
Joined: Feb 19, 2011
Posts: 159
|
|
|
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: 3795
|
|
|
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: 159
|
|
|
sir can you please example in details
|
 |
Henry Wong
author
Sheriff
Joined: Sep 28, 2004
Posts: 16695
|
|
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: 5901
|
|
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."
|
 |
 |
|
|
subject: wait and notify method method
|
|
|