I found a mysterious problem with a Java code for homework. A friend program an application which this at the beginning :
public void run() {
vm.setVisible(true);
while(!end);
System.out.println("Finish");
vm.setVisible(false);
}
The boolean 'end' is false while all the execution and when the user quits the application this happens:
private class CloseSys implements ActionListener {
public CloseSys() {super();}
public void actionPerformed(ActionEvent e) {
System.out.println("CLOSE SYS");
System.out.println("end: "+end);
end = true;
System.out.println("end: "+end);
}
}
The println shows like the value of 'end' changes to true and logically in my friend's computer (MacOS) the while finish and the application too.
The problem is that in my computer (Ubuntu Linux) the println also shows like the value changes but the while doesn't ends (the "Finish" println is never reached). The funny thing about it is if we put prints into the while... then works!