This isn't really a bug as the code in question is just an example for benchmarking purposes, but it's a bit surprising to see the following code in the JMH tutorials:
volatile double x = Math.PI;
...
x++;
Isn't incrementing a volatile field like that always a bug in real code, due to lack of atomicity? I wonder if someone reads this and thinks it's something Java lets you do.
volatile double x = Math.PI;
...
x++;
Isn't incrementing a volatile field like that always a bug in real code, due to lack of atomicity? I wonder if someone reads this and thinks it's something Java lets you do.
- links to
-
Review(master) openjdk/jmh/145