thread

abalfazl hossein

Ranch Hand

Posts: 635

posted 9 years ago

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

posted 9 years ago

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.