The following program prints 10 and 5. I understand the first value printed;i.e.10 but I am not clear why it is printing 5 in the second print statement rather than 10. Thanks in advance for any helps.
public class
test implements Runnable
{
int x = 5;
public void run()
{
this.x = 10;
}
public static void main(
String[] args)
{
test tc = new test();
System.out.println(tc.x); // First value of tc.x
new
Thread(tc).start();
System.out.println(tc.x); // Second value of tc.x
}
}