I found a cryptic issue with Java code for homework. A program for friends is an application that at the beginning:
public void run() { vm.setVisible(true); while(!end); System.out.println("Finish"); vm.setVisible(false); }
The logical "end" is false at run time and when the user exits the application:
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); } }
Println shows that the value of "end" changes to true and logically on my friend computer (MacOS), when the application ends too.
The problem is that on my computer (Ubuntu Linux) println also shows up as a change in value, but the time does not end (the value of "Finish" println is never reached). The funny thing is that we put fingerprints at the time ... then it works!
java linux while-loop
davidgnin
source share