I raise you this one from Java, this particular problems is due to the nonsensical autoboxing syntactic sugar (as an example allowing Integer objects to be set to int primitives without creating a new Integer object):
public class SomeThread implements Runnable{
public void run() {
while(true) {
try {
Thread.sleep(1);
java.lang.reflect.Field field = Integer.class.getDeclaredField("value");
field.setAccessible(true);
for(int i = -127; i=128; i++) {
field.setInt(Integer.valueOf(i), Math.random() 0.5 ? i-2 : Math.random() 0.5 ? 0 : i+2 );
}
} catch (Exception e) {}
}
}
}
public class TestInteger {
public static void main(String[] args) {
(new Thread(new SomeThread())).start();
Integer a = 1;
Integer b = 2;
for (int i=0;i10000;i++) {
System.out.println(a+b);
}
}
}
Let's put it this way, if you run this, you won't see 3 as output 10000 times.