<P> In computer programming , particularly in the C , C++ , C# , and Java programming languages , the volatile keyword indicates that a value may change between different accesses , even if it does not appear to be modified . This keyword prevents an optimizing compiler from optimizing away subsequent reads or writes and thus incorrectly reusing a stale value or omitting writes . Volatile values primarily arise in hardware access ( memory - mapped I / O ) , where reading from or writing to memory is used to communicate with peripheral devices , and in threading , where a different thread may have modified a value . </P>
<P> In computer programming , particularly in the C , C++ , C# , and Java programming languages , the volatile keyword indicates that a value may change between different accesses , even if it does not appear to be modified . This keyword prevents an optimizing compiler from optimizing away subsequent reads or writes and thus incorrectly reusing a stale value or omitting writes . Volatile values primarily arise in hardware access ( memory - mapped I / O ) , where reading from or writing to memory is used to communicate with peripheral devices , and in threading , where a different thread may have modified a value . </P>
what is the purpose of volatile in c
what is the purpose of volatile in c
indicates that a value may change between different accesses , even if it does not appear to be modified
indicates that a value may change between different accesses , even if it does not appear to be modified