"Suppose d is the object we're using to invoke wait. When a thread invokes d.wait, it must own the intrinsic lock for d — otherwise an error is thrown. Invoking wait inside a synchronized method is a simple way to acquire the intrinsic lock."
Jon Camilleri wrote:
How would you code the assertion that a thread owns an intrinsic lock?
The Thread class has a holdsLock() method. This method can be use to check if a thread owns the lock -- and interestingly, the JavaDoc specifically provides an example of it as an assertion.
Jon Camilleri wrote:
How would you code the assertion that a thread owns an intrinsic lock?
The Thread class has a holdsLock() method. This method can be use to check if a thread owns the lock -- and interestingly, the JavaDoc specifically provides an example of it as an assertion.
Henry
I had no idea where to look, so I must be starting to think like a Java programmer