🔥 Burn Fat Fast. Discover How! 💪

What is Biased Locking and why it became deprecated? #lock #co | Java Tech News

What is Biased Locking and why it became deprecated?
#lock #concurrency #jep
Biased Locking — an optimization in the VM that leaves an object as logically locked by a given thread even after the thread has released the lock. The idea was to optimize common situation when a thread reacquires the lock — then reacquisition can be achieved at very low cost, which saved about two compare-and-swap atomic operations. The downside was in the expensive revocation operation when another thread decides to acquire the lock.

JEP 374 has been released in Java 15 following deprecation and disabling of biased locking. Applications that benefit from this optimization are now considered legacy and will never migrate to newer versions. Newer applications generally use the non-synchronized collections (e.g., HashMap and ArrayList) or concurrent collections from Java 5. Biased locking introduced a lot of complex code into JDK and HotSpot and it is going to be refactored in newer versions.
https://openjdk.java.net/jeps/374