• Post Reply Bookmark Topic Watch Topic
  • New Topic

thread

 
abalfazl hossein
Ranch Hand
Posts: 635
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello

May you explain about this?
You can ask another object to perform an operation that manipulates its own lock. To do this, you must first capture that object´┐Żs lock. For example, if you want to notify( ) an object x, you must do so inside a synchronized block that acquires the lock for x:


 
ahmed yehia
Ranch Hand
Posts: 424
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

if you want to notify( ) an object x, you must do so inside a synchronized block that acquires the lock for x:

This is because in order to call wait() notify() notifyAll() on an object, the thread first must acquire the lock for that object.
This can be done by synchronizing the code that is making these method calls.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!