Remember, there is a thread running that is executing your application. This thread is often known as the main thread and executes, oddly enough, your main method. This thread is started by the JVM when you run your application.
Now, in Line 1 of your example, you're launching a new user thread that will begin executing the run() method of the class TestClass.
Now, just after you start that thread, the main thread tries to output the value of tc.x. However, the new thread that you just started is trying to modify that value. So which happens first? Does the value get changed by your thread or does it get printed by the main thread? Obviously, the order in which these operations occur will impact the final output of this application.
The answer is: we don't know. How threads are handled and how context switching is done is JVM and operating system dependent. How this application runs on a Windows machine might be different that on UNIX and might still be different than on a Macintosh. Becuase context switching is handled differently on different systems, we can't possibly guarantee what the result of running this application might be. It might even produce different results from one execution to the next on the same machine.
I hope that helps,
Corey
[ March 27, 2002: Message edited by: Corey McGlone ]