posted 19 years ago
You do, indeed, create two threads, but you're only creating one instance of the class TestClass, which contains your x and y variables. As you're passing a reference to the same TestClass object to each thread, each thread has a reference to a single, shared object and, likewise, shared x and y variables.
Had you done this:
Then each thread would have a reference to a unique TestClass object and they would, in turn, have their own x and y variables.
I hope that helps,
Corey