Does anybody know of a test that reproduces "broken double checked locking" problem in java?
Asked
Active
Viewed 145 times
0
-
1http://www.cs.umd.edu/~pugh/java/memoryModel/DoubleCheckTest.java and see this article: http://www.cs.umd.edu/~pugh/java/memoryModel/DoubleCheckedLocking.html – Alex Nov 27 '12 at 05:49
-
1Well the test isn't a problem. The problem is to find a platform and environment that maximizes likelihood of DCL failure. Unfortunately for you x86 has rather strong memory model :) – Nov 27 '12 at 12:35
1 Answers
3
Checkout this project: java-concurrency-torture. It is written by Alexey Shipilev. He is Java Performance Engineer who works at Oracle. Here is a bunch of tests for different kinds of singleton initialization practices.
Important: To maximize your chances to see DCL bug you should run these tests with -server
flag on 32-bit jvm.