Question

I learnt that:"Every object has an intrinsic lock associated with it."

I also learnt that on linux, JVM internally uses POSIX api's for multi-threading feature.

What is the name of the POSIX api that JVM uses to provide(create) an intrinsic lock for each object instance of a class?

Was it helpful?

Solution

The locks the JVM use to implement synchronized are not operating system locks, but is implemented internally in the JVM.

This is for speed reasons as well as they lock something different. The operating system has no special understanding of Java objects (as opposed to files, memory and so on) so the JVM has its own locking mechanism specially designed for this.

A lot of effort has gone into making this very fast.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top