CWE-609

Double-Checked Locking

Medium

Description

The product uses double-checked locking to access a resource without the overhead of explicit synchronization, but the locking is insufficient.

Potential Impact

How to Fix

Implementation

While double-checked locking can be achieved in some languages, it is inherently flawed in Java before 1.5, and cannot be achieved without compromising platform independence. Before Java 1.5, only use of the synchronized keyword is known to work. Beginning in Java 1.5, use of the "volatile" keyword allows double-checked locking to work successfully, although there is some debate as to whether it achieves sufficient performance gains. See references.

Detection Methods

Related Weaknesses

References

View on MITRE CWE Database →

Need Help Fixing This Vulnerability?

Our security experts can help you identify and remediate CWE-609 vulnerabilities in your codebase.

Get Security Assessment