package java.lang;
import java.util.Random;
public final class Math {
private static Random randomNumberGenerator;
private static synchronized void initRNG() {
if (randomNumberGenerator == null)
randomNumberGenerator = new Random();
}
public static double random() {
if (randomNumberGenerator == null) initRNG();
return randomNumberGenerator.nextDouble();
}
}
Thursday, November 22, 2007
Double-Checked Locking found in JVM
I just found an implementation of the broken double checked locking in the java 6 runtime library!
Here is a snippet of the offending code:
Amazingly, it used to work correctly, but the extra synchronization was removed in java 1.3. You can track the progress of this bug in report 6470700 and report 6633229.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment