It seems to me that there is a possibility for check to return true, if Thread A calls setX and returns (releasing the lock) but Thread B is allowed to call check() before A can call setY.
public void setXY (int i) {
setX(i); // setX is synchronized
setY(i); // setY is synchronized
}
public synchronized boolean check() {return X != Y; }
But this does not exactly match any of the options because the critical point is not the number of Threads calling setXY, but the fact that check is being called while a Thread calls setXY. If I had to pick an option I would pick B.
Bill
------------------
author of: