ThinLocks are a fast implementation of locks for a multithreaded environment (for example, object monitors in Java, the job for which they were invented). In particular, they're fast for uncontended acquisitions, which are the most common case in many situations. * http://www.research.ibm.com/people/d/dfb/thinlocks.html Basically, they work by providing two levels of locks: a very simple lock, which takes up a single word of space in an object and can be acquired and released with a very small number of instructions (a compare-and-swap to acquire, a store to release), but which can't handle queueing, and a more heavyweight lock, which is bulky and slow, but which can handle contention (a normal semaphore, basically), and which is lazily created when the simple lock gets contended. ThinLocks were invented by compiler genius DavidBacon, of InternationalBusinessMachines, and have been much played with and improved on since then. The design works because, even though handling contention is slower than in a conventional semaphore, uncontended locks are dramatically faster, and uncontended locks are the common case. This is a fine example of how RidiculousSimplicityGivesRidiculousResources. ---- CategoryConcurrency