Volatile (computer programming): Difference between revisions

Content deleted Content added
Jc00 (talk | contribs)
m Corrected typo in external link description
If the variable is between mutex locks, volatile is not necessary
Line 1:
In [[computer programming]], a [[variable]] or object declared with the '''volatile''' [[keyword (computer programming)|keyword]] may be modified externally from the declaring object. For example, a variable that might be concurrently modified by multiple [[thread (computer science)|thread]]s shouldmay be declared volatile. Variables declared to be volatile will not be [[compiler optimization|optimized]] by the [[compiler]] because the compiler must assume that their values can change at any time. Note that operations on a volatile variable are still not guaranteed to be [[atomic operation|atomic]].
 
==What can happen if volatile is not used?==