Sun's JDK for the Mac 1.0.2 behaved similarly. However it skipped 7 and stopped at 107:
1 2 3 4 5 6 8 9 10 11 ... 98 99 100 101 102 103 104 105 106 107
Can you explain this behavior? How do you get an infinite loop one
run, and termination the next with no external input to the
program? Why do different VMs give different results? Why is this
program non-deterministic? There are no calls to Math.random()
. There's no user input. Nothing reads anything
from the host machine such as the number of active processes
running or the current time. It's just a simple counting program!