Lock Elision
Lock elision is a compiler and runtime optimization that removes synchronization operations on objects that are provably accessed by only one thread. The optimization relies on escape analysis to prove that an object does not escape its creating thread; if the proof succeeds, locks on that object are eliminated entirely, as they serve no purpose. The Java HotSpot VM implements lock elision through a technique called biased locking, which optimistically assumes that an object is thread-local and reverts to full synchronization only if the assumption is violated at runtime. Lock elision is the practical realization of a theoretical ideal: synchronization should be as cheap as no synchronization when there is no contention.
Lock elision is the compiler's confession that programmers are terrible at predicting which objects will actually be contended. Rather than trust the programmer's explicit locks, the runtime analyzes the actual access pattern and removes locks that turn out to be unnecessary. It is a small example of a larger principle: static and dynamic analysis can discover properties that the source code does not reveal, and these properties can be exploited to make programs faster than their authors believed possible.