language-icon Old Web
English
Sign In

Double-checked locking

In software engineering, double-checked locking (also known as 'double-checked locking optimization') is a software design pattern used to reduce the overhead of acquiring a lock by testing the locking criterion (the 'lock hint') before acquiring the lock. Locking occurs only if the locking criterion check indicates that locking is required.If control enters the declaration concurrently while the variable is being initialized, the concurrent execution shall wait for completion of the initialization. In software engineering, double-checked locking (also known as 'double-checked locking optimization') is a software design pattern used to reduce the overhead of acquiring a lock by testing the locking criterion (the 'lock hint') before acquiring the lock. Locking occurs only if the locking criterion check indicates that locking is required. The pattern, when implemented in some language/hardware combinations, can be unsafe. At times, it can be considered an anti-pattern. It is typically used to reduce locking overhead when implementing 'lazy initialization' in a multi-threaded environment, especially as part of the Singleton pattern. Lazy initialization avoids initializing a value until the first time it is accessed.

[ "Record locking", "Concurrency control" ]
Parent Topic
Child Topic
    No Parent Topic