, lock object itself is locked, the markword heavyweight lock pointer is stored inside the lock?
O, thanks!
CodePudding user response:
In the Java language specification (Java se 8) version 17.1 section with a statement like this: "Each object in the Java is associated with a monitor, which a thread can lock or unlock. Only one thread at a time may hold a lock on a monitor. Any other threads attempting to lock that monitor are blocked until they can obtain a lock on the monitor." this is the original connection, Java is the translation of Each object that is associated with a monitor, a thread can lock or unlock the monitor. At the same time there is Only one thread can lock an object monitor. And try to lock the monitor all other threads will be blocked, until they can get on the monitor lock.Back to your question, after the upgrade for the heavyweight lock Java object lock head save as Monitor object pointer. Here you see its structure and method of the Monitor objectMonitor. CPP link
ObjectMonitor HPP links