I had something similar to the following code:
while (!stopThread){}
System.out.println("ending thread");
where stopThread was set to true once the thread was ready to end, and I had confirmed that stopThread was properly being set to true. However the line below the while loop was never printed. Although, if I add a print line to the inside of the loop then the "ending thread" message will get printed. Furthermore, if I just increment some arbitrary count value within the loop but never do anything with the value it also does not get to then end print statement. It seems as though an iteration of a while loop only occurs if it is of consequence, thus the condition will not get checked if the loop does not do anything meaningful. Is this correct? Is this only a feature of Java? What is a best practice way to keep a loop running that is just meant to run without doing anything?