During bug fixing in very old project I\'ve faced with strange method, it looks like this:
void waiter() {
for (int i = 0; i < 20000; i++) ;
I don't know if it has changed, I haven't used java for 2 years but it doesn't seem to.
http://www.herongyang.com/JVM/Benchmark-Int-Empty-Loop-16-Nanosecond.html http://www.herongyang.com/JVM/Benchmark-Long-Empty-Loop-25-Nanosecond.html
This test also confirms that the Java bytecode compiler "javac" is not doing any optimization to replacing the empty loop with "i=steps" which is the net effect of the loop.