Double-checked locking
Design pattern only locking if the locking criterion check indicates that locking is required
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.
Nº Q2712542 ★
Common · History
Double-checked locking
Design pattern only locking if the locking criterion check indicates that locking is required
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.
From Wikipedia
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 original form of the pattern, appearing in Pattern Languages of Program Design 3, has data races, depending on the memory model in use, and it is hard to get right. Some consider it to be an anti-pattern. There are valid forms of the pattern, including the use of the volatile keyword in Java and explicit memory barriers in C++. The pattern 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.
Text: Wikipédia, CC BY-SA 4.0. ·
Related cards
-
R
Reactor pattern
Event handling pattern for handling service requests delivered concurrently to a service handler by one or more inputs; the service handler then demultiplexes the incoming requests and dispatches them synchronously to the associated request handlers
Nº Q1122024 ★
Not listed
-
C
Circuit breaker design pattern
Behavioral design pattern in software development
Nº Q5121595 ★
Not listed
-
Service locator pattern
Software pattern to dynamically control the loading of objects at run-time via a central registry object.
Nº Q7455762 ★
Not listed
-
Double Ratchet Algorithm
Cryptographic key management algorithm
Nº Q22079944 ★
Not listed
-
Dynamic logic (digital electronics)
Design methodology in combinatorial logic circuits
Nº Q2351326 ★
Not listed
-
Dependency injection
Technique in software engineering
Nº Q635336 ★★★
Not listed