• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

objects and threads

 
sylvia greene
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 7729
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic