It is generally accepted (I believe!) that a lock
will force any values from fields to be reloaded (essentially acting as a memory-barrier or fence - my terminology
Further to Michael Burr's answer, not only does Wait
release and re-acquire the lock, but it does this so that another thread can take out the lock in order to examine the shared state and call Pulse
. If the second thread doesn't take out the lock then Pulse
will throw. If they don't Pulse
the first thread's Wait
won't return. Hence any other thread's access to the shared state must happen within a proper memory-barried scenario.
So assuming the Monitor
methods are being used according to the locally-checkable rules, then all memory accesses happen inside a lock, and hence only the automatic memory barrier support of lock
is relevant/necessary.