java basis - synchronized implementation principle

Java object instance :

 

 

 Object header : a MarkWord (32), Class Metadata Address (address class metadata, i.e., a pointer to the object metadata of its class, 32), the length of the array (when the object is an array, 32).

Mark Word :

 

 

 

Monitor : is a synchronization tool, built into every object, every object has a Monitor, the equivalent of a license (lock), to get a license to access the object.

 

 

 

 Synchronized 1.6 after optimization :

Guess you like

Origin www.cnblogs.com/lankerenf3039/p/12081282.html