T
The Daily Insight

Is double-checked locking safe?

Author

David Jones

Published May 01, 2026

Is double-checked locking safe?

Since only the first access requires locking, double-checked locking is used to avoid locking overhead of subsequent accesses. However, on many languages and hardware, the design can be unsafe.

Why double-checked locking is bad?

Note that there is actually no classic “double-check” pattern, since without the above fixes the pattern cannot work. This is why the double-check pattern is considered evil, since you simply can’t implement it correctly without atomics and fences.

Why do they double check locks?

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.

Does double-checked locking work in Java?

Double-Checked Locking is widely cited and used as an efficient method for implementing lazy initialization in a multithreaded environment. Unfortunately, it will not work reliably in a platform independent way when implemented in Java, without additional synchronization.

What is the use of double checked locking in singleton?

In double-checked locking, code checks for an existing instance of Singleton class twice with and without locking to make sure that only one instance of singleton gets created.

Is double checked?

To double-check means to review something twice, to be sure that no mistakes have been made. When accuracy is extremely important, one may be asked to triple-check data. However, triple-check is not currently a word recognized by the Oxford English Dictionary.

What is double checked locking in Singleton?

What’s another word for double check?

What is another word for double-check?

checkverify
make surereassure yourself
confirmmake certain
ascertainestablish
seecheck out

Why volatile is used in singleton?

The volatile prevents memory writes from being re-ordered, making it impossible for other threads to read uninitialized fields of your singleton through the singleton’s pointer.

Why do we need volatile in singleton?

How can singleton be broken?

Serialization:- Serialization can also cause breakage of singleton property of singleton classes. Suppose you serialize an object of a singleton class. Then if you de-serialize that object it will create a new instance and hence break the singleton pattern.

Is Double confirm grammatically correct?

If you’re using the word “confirm” to verify something, just use the word “confirm”. To add “double” before “confirm” is unnecessary because “confirm” already implies something is definite. If you’ve already confirmed something once, and you would like to confirm it again, you can use the word “reconfirm”.