What is biased locking (historic) in Java?

Biased locking is a mechanism in Java designed to optimize thread contention in synchronized code blocks. It allows a thread to take ownership of an intrinsic lock for an object without having to acquire it explicitly, thereby reducing the overhead of locking mechanisms. When a thread enters a synchronized block, it can quickly check if it is the owner of the lock. If it is, it can skip the overhead of acquiring the lock again. This feature significantly improves performance in scenarios where locks are predominantly held by the same thread.

In Java’s historic implementation, biased locking was introduced to reduce the latency associated with uncontended locks. However, it could lead to issues when a thread was not the original owner of the lock, resulting in potentially increased contention when the bias had to be revoked.

Despite its advantages, biased locking was disabled by default in later versions of the HotSpot JVM due to complexities in managing lock ownership and contention dynamics. It is important for developers to understand these locking mechanisms for efficient multithreaded programming.


Java biased locking synchronization multithreading JVM performance