posted 18 years ago
Probably, you were not very lucky....
As soon as you call whiz.start(); a new thread comes to life (other one is your main thread). Now, in your case, before the new thread could reach value++; thread scheduler gave chance to the main thread to run, and the main thread completed the stmt ' System.out.println("The value of the integer variable is: "+Temp.value);' before value is actually incremented.
Again, this may not be the case always.
Just try and put Thread.sleep(100); after whiz.start() and you'll see the difference. Hope that clears.