I got two threads running on Main.java and a boolean field Main.bool which is false in the beginning. The first thread will set Main.bool to true. After that, The second thread will print out Main.bool. And the result is FALSE.
More interesting, I tried to print out a random text before printing Main.bool, then the result turned out to be correct(true).
Anyone have an idea what is going on here? I'm using eclipse Kepler.
Main.bool = false;
thread1.setBool(true);
// then wait for some seconds
// case 1
thread2.printBool(); --> false
// case 2
System.out.println("blah blah");
thread2.printBool(); --> true