Home > Back-end >  Answer [o] heavyweight lock related issues
Answer [o] heavyweight lock related issues

Time:12-02

"Deep understanding of the JAVA virtual machine," the book said: when lightweight locks to upgrade to the heavyweight locks, lock object markword store is a pointer to the heavyweight lock,
, 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
  • Related