Return an immutable non-final member from within a synchronized block – race condition?

Consider the following class:

class SynchronizedInt { 
    private int x;
    private final Object lock = new Object();

    public void set(int xIn) {
        synchronized (lock) {
            x = xIn;
        }
    }

    public int getIfGreater(int y) {
        synchronized (lock) {
            if (x>y) {
                return x;
            }
            return 0;
        }
    }
 }

SynchronizedInt i:
// ... code ...
int j = i.getIfGreater(10)   // assume x > 10, is j guaranteed to be > 10?

When calling getIfGreater, provided the condition x>y returns true, am I guaranteed to get the same x that was tested in the condition?

What I’m thinking is that there might be some optimization that causes the return value to reference the SynchronizedInt instance’s x, and then set might get called from another thread and change it.