posted 22 years ago
A) isnt right, because of B)
Answer B) is right.
A call to setXY makes calls to the synchronized methods setX / setY.
But the method setXY isn't synchronized. So it can be called by multible threads.
Ex:
When thread1 call setXY(8), method setX(8) called.
Here comes thread2 with call setXY(9).
Thread1 leaves setX(8) and call setY(8).
Now Thread2 can enter setX(9)
Thread1 call check() and ups! x==9, y==8!
C) Can't happen, cause setX/setY are private
D) completely beside it