FULL PRODUCT VERSION :
java -jre7
java -1.8.0_121
java -1.8.0_131
ADDITIONAL OS VERSION INFORMATION :
Windows 7 Professional x64
EXTRA RELEVANT SYSTEM CONFIGURATION :
N/A - Tested on multiple windows systems
A DESCRIPTION OF THE PROBLEM :
while(!condition) {
//empty body no code
}
Loop does not terminate when condition is satisfied.
condition = true
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
public class Test {
public static void main(String[] args) throws Exception {
new Thread(new Runnable() {
@Override
public void run() {
start();
}
}).start();
Thread.sleep(100);
stopRunning = true;
System.out.println("But it didn't end?");
}
private static boolean stopRunning = false;
public static void start() {
while (!stopRunning) {
}
System.out.println("Method ended.");
}
}
Please see that System.out.println("Method ended."); does not execute and application will not terminate
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
I was trying to pause the application until a condition was achieved.
ACTUAL -
System.out.println("But it didn't end?"); printed however System.out.println("Method ended."); did not. I can see that if you call the method again under System.out.println("But it didn't end?"); the method will terminate however the issue will still be present with the next execution of the method.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
No errors, no crashes.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
public class Test {
public static void main(String[] args) throws Exception {
new Thread(new Runnable() {
@Override
public void run() {
start();
}
}).start();
Thread.sleep(100);
stopRunning = true;
System.out.println("But it didn't end?");
}
private static boolean stopRunning = false;
public static void start() {
while (!stopRunning) {
}
System.out.println("Method ended.");
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Not bypass has been found
java -jre7
java -1.8.0_121
java -1.8.0_131
ADDITIONAL OS VERSION INFORMATION :
Windows 7 Professional x64
EXTRA RELEVANT SYSTEM CONFIGURATION :
N/A - Tested on multiple windows systems
A DESCRIPTION OF THE PROBLEM :
while(!condition) {
//empty body no code
}
Loop does not terminate when condition is satisfied.
condition = true
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
public class Test {
public static void main(String[] args) throws Exception {
new Thread(new Runnable() {
@Override
public void run() {
start();
}
}).start();
Thread.sleep(100);
stopRunning = true;
System.out.println("But it didn't end?");
}
private static boolean stopRunning = false;
public static void start() {
while (!stopRunning) {
}
System.out.println("Method ended.");
}
}
Please see that System.out.println("Method ended."); does not execute and application will not terminate
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
I was trying to pause the application until a condition was achieved.
ACTUAL -
System.out.println("But it didn't end?"); printed however System.out.println("Method ended."); did not. I can see that if you call the method again under System.out.println("But it didn't end?"); the method will terminate however the issue will still be present with the next execution of the method.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
No errors, no crashes.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
public class Test {
public static void main(String[] args) throws Exception {
new Thread(new Runnable() {
@Override
public void run() {
start();
}
}).start();
Thread.sleep(100);
stopRunning = true;
System.out.println("But it didn't end?");
}
private static boolean stopRunning = false;
public static void start() {
while (!stopRunning) {
}
System.out.println("Method ended.");
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Not bypass has been found
- relates to
-
JDK-8228899 While loop does not break on boolean condition
- Closed