Runnable jcstress + JUnit companion for the ankurm.com post on the Java Memory Model, double-checked locking, and the volatile fix.
22 lines
808 B
Plaintext
22 lines
808 B
Plaintext
$ java -jar target/jcstress.jar -t VolatilePublicationTest -jvmArgs "-Xmx256m" -f 2 -iters 15 -time 1000
|
|
|
|
RUN RESULTS:
|
|
Interesting tests: No matches.
|
|
|
|
Failed tests: No matches.
|
|
|
|
Error tests: No matches.
|
|
|
|
All remaining tests: 1 matching test results.
|
|
|
|
.......... [OK] com.ankurm.jmm.VolatilePublicationTest
|
|
|
|
Results across all configurations:
|
|
|
|
RESULT SAMPLES FREQ EXPECT DESCRIPTION
|
|
0, 0 4,290,607,784 80.26% Acceptable Reader ran before the write was published at all.
|
|
0, 1 0 0.00% Forbidden Would mean the volatile happens-before edge failed to hold.
|
|
1, 0 0 0.00% Forbidden Would mean the volatile happens-before edge failed to hold.
|
|
1, 1 1,055,076,014 19.74% Acceptable Reader saw the fully-constructed Payload.
|
|
|