<Li> In all versions of Java, there is a global ordering on reads and writes of all volatile variables (this global ordering on volatiles is a partial order over the larger synchronization order (which is a total order over all synchronization actions)). This implies that every thread accessing a volatile field will read its current value before continuing, instead of (potentially) using a cached value . (However, there is no guarantee about the relative ordering of volatile reads and writes with regular reads and writes, meaning that it's generally not a useful threading construct .) </Li> <Li> In Java 5 or later, volatile reads and writes establish a happens - before relationship, much like acquiring and releasing a mutex . </Li> <P> Using volatile may be faster than a lock, but it will not work in some situations . The range of situations in which volatile is effective was expanded in Java 5; in particular, double - checked locking now works correctly . </P> <P> In C#, volatile ensures that code accessing the field is not subject to some thread - unsafe optimizations that may be performed by the compiler, the CLR, or by hardware . Only the following types can be marked volatile: all reference types, Single, Boolean, Byte, SByte, Int16, UInt16, Int32, UInt32, Char, and all enumerated types with an underlying type of Byte, SByte, Int16, UInt16, Int32, or UInt32 . (This excludes value structs, as well as the primitive types Double, Int64, UInt64 and Decimal .) </P>

What is meant by static int in c