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++) ;
}
Does it cause halting some time or it will be omitted by JVM optimization?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It will be optimized after few runs by JIT. The JVM , at the first run, needs to check if the value if
ithat is being incremented is not being used anywhere.Check this article as well :
Java: how much time does an empty loop use?