简体   繁体   中英

Query on implementation of lock mechanism in java

As mentioned in Doug Lea's "Concurrent Programming in Java",

Every instance of class Object (and its subclasses) possesses a lock that is obtained on entry to a synchronized method and automatically released upon exit.

Does JVM implement lock mechanism completely in user space?

or

Does JVM rely on OS kernel space system calls to implement lock? Please provide reference to the code that implements lock mechanism.

Note: New to java multi-threading

Does JVM implement lock mechanism completely in user space?

Mostly, but not completely.

Does JVM rely on OS kernel space system calls to implement lock?

It tries to handle the lock in user space but if the lock cannot be obtained for a while, it drops back to an OS lock.

The reference implementation is in the OpenJDK, which you free to download.

New to java multi-threading

Getting buried/lost in the details might not be very helpful.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM