hi all:
See this code:
public class TestClass implements Runnable
{
int x = 5;
public void run()
{
this.x = 10;
}
public static void main(
String[] args)
{
TestClass tc = new TestClass();
new
Thread(tc).start(); // 1
System.out.println(tc.x);
}
}
what will it print when run?
a) 5
b) 10
c) It will not compile
d) Exception at runtime
e) The output can not be determined
I choosed a)5. However, the correct answer is: e) The output can not be determined. I don't know why. I think according to
Java's "Pass by Value" theory,it always print 5.
Please help me.
Thanks.