I have this code
while(!decks.get(0).isEmpty()){
SingleCardWindow obj = new SingleCardWindow(decks.get(0).take());
while(obj.isVisible()){
}
System.out.println("Closed");
}
SingleCardWindow it is inherit-class from JFrame. This code displays all cards from the deck. Displays one card, wait until I close this window, and displays next card. In Windows it works well.
In linux (java-oracle-7) "Closed" never writing!
But if I make
while(!decks.get(0).isEmpty()){
SingleCardWindow obj = new SingleCardWindow(decks.get(0).take());
while(obj.isVisible()){
System.out.println("SOMETHING");
}
System.out.println("Closed");
}
program works right. So, i think that compiler optimize "while(obj.isVisible())" like "while(true)". What I should do with this? I dont needs any code into the loop.
obj.isVisible()is reading from non-volatilemembers, without explicit synchronization.