Tuesday, December 8, 2009

Thin locks, Fat Locks, contended thin lock etc

voir http://download.oracle.com/docs/cd/E13188_01/jrockit/docs142/usingJRA/applocks.html

A Thin Lock is one on which there is little contention, and only by spinning threads (the thread trying to acquire the lock is not suspended, but it keep polling the lock until it's available).
Such a Thin Lock with only Spinning Threads is called contended thin lock.

When there is more contention, a Thin Lock is promoted to Fat Lock, and a list is made with all threads waiting to acquire the lock.
Threads trying to acquire a fat lock go to sleep, and are called contended fat lock.

A Fat Lock might deflate to a Thin Lock if the JVM believes there is not much contention on the lock.

No comments: