Sorry, but I still cannot figure it out.
Is there any possibility like this: after one thread just finishes setX(), it will release the monitor, and meanwhile the other thread can get the monitor and grasp CPU in turn, which runs check() at once, then it seems that x and y are not equal at that time.
Thank you for helping me!