synchronized vs. C volatile

dsimcha dsimcha at yahoo.com
Mon Aug 9 06:25:46 PDT 2010


== Quote from SK (sk at metrokings.com)'s article
> Does 'synchronized' mean the exact same thing as the C 'volatile'
> qualifier when applied to basic types?
> As in:
> synchronized int x;

They're completely different.  synchronized is basically a scoped mutex and
applies to a statement, not a variable declaration.  I have no idea what your
example does, but it probably shouldn't even compile.  Volatile just prevents
certain compiler optimizations that can interfere with updates to a variable from
other hardware besides the CPU and is useful for things like device drivers.


More information about the Digitalmars-d mailing list