File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes objects and threads Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "objects and threads" Watch "objects and threads" New topic
Author

objects and threads

sylvia greene
Ranch Hand

Joined: Jun 23, 2004
Posts: 40

A thread can't invoke a wait or notify method on an object unless it owns that objects lock


I can't the concept of object here.




What is a thread and what is a object here?



Isn't "b" both an object and thread? what's object being referred to here.
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
Yes, in this case, b is an object and a Thread (Thread is derived from object). The wait() and notify() are being called on the shared object b The b in the main method refers to the same object as this in the run method of object b.


Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
 
 
subject: objects and threads
 
Similar Threads
notify(); doesn't work?
problem with wait()- notify()
thread doubt
Lock Mechanism ?
wait and notify..test