Runnable jcstress + JUnit companion for the ankurm.com post on the Java Memory Model, double-checked locking, and the volatile fix.
22 lines
819 B
Plaintext
22 lines
819 B
Plaintext
$ java -jar target/jcstress.jar -t FinalFieldPublicationTest -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.FinalFieldPublicationTest
|
|
|
|
Results across all configurations:
|
|
|
|
RESULT SAMPLES FREQ EXPECT DESCRIPTION
|
|
0, 0 3,697,560,129 66.13% Acceptable Reader ran before the write was published at all.
|
|
0, 1 0 0.00% Forbidden Would mean the final-field safe-publication guarantee fai...
|
|
1, 0 0 0.00% Forbidden Would mean the final-field safe-publication guarantee fai...
|
|
1, 1 1,893,699,349 33.87% Acceptable Reader saw the fully-constructed FinalPayload.
|
|
|