Consider a volatile int sharedVar. We know that the JLS gives us the following guarantees:
w precedi
Please see this section (17.4.4). you have twisted the specification a bit, which is what is confusing you. the read/write specification for volatile variables says nothing about specific values, specifically:
UPDATE:
As @AndrzejDoyle mentions, you could conceivably have thread r read a stale value as long as nothing else that thread does after that point establishes a synchronization point with thread w at some later point in the execution (as then you would be in violation of the spec). So yes, there is some wiggle room there, but thread r would be very restricted in what it could do (for instance, writing to System.out would establish a later sync point as most stream impls are synchronized).