In your code above, the methods addX() and addY() are not synchronized, therefore they can be executed by more than one
thread at a time.
Only when you synchronize the methods you can guarantee that it will give the same result everytime it runs.
Also remember that thread scheduler, is platform dependant, therefore you can see the same output on your machine everytime you run the program, but if you move to another OS, you may get different result. that's why answer C is correct.
hope that helps!
I think answer C should be re-worded as
Will print but not
necessarily in an order (eg: 123124 3)
[ July 28, 2002: Message edited by: Amir Ghahrai ]