locks on X86
Jeff Sturm
jsturm@one-point.com
Thu Mar 15 07:06:00 GMT 2001
On 2001年3月14日, Boehm, Hans wrote:
> I believe that if x and y are globally visible, then
>> x = ...
> synchronized(local){}
> y = ...
>> still ensures that the assignment to x precedes that to y (for a suitable
> definition of what that means), eventhough no useful mutual exclusion is
> provided.
Interesting. So that would behave as if x,y were declared volatile (if
volatile worked at all).
> Still a memory barrier is likely to be much cheaper than a full
> synchronization, especially on X86 where it may affect only reordering by
> the compiler.
Oh yes. Even a simple lock/unlock sequence can issue up to three
membars on some non-X86 machines. (Actually your example could be
satisifed by a single "wmb" which is cheaper still.)
Jeff
More information about the Java
mailing list