0

Given the following code

var cachedInt = new ArrayBlockingQueue<Integer>(xxxxx);

while(true){
   while(cachedInt.offer(randomProvider.nextInt()));
   latch.await();
}

Will the jvm eventually eliminate the while loop because it has no body or does it recognize the side effect of the condition and keep the loop in place?

Kilian
  • 1,540
  • 16
  • 28

1 Answers1

0

No the jvm will not "optimize" your method call away. Your condition will run repeatedly until it returns false and the side effects will happen as normal.

mypetlion
  • 2,415
  • 5
  • 18
  • 22