Reason:
You may or may not get true for check method even if you use multiple threads to call setXY() method. The reason is, no
thread is willing to give the CPU cycles to other threads to do their work (i.e) sleep/yield should be there so that other threads can also do their job. If the underlying OS uses time slicing mechanism, then you may get true for check method. \
I modified your code, sothat check can return true.
Note: Only SetX and SetY are synchronized methods, not SetXY. Hence it can be called by more than one thread at a time.