FlexTrade Interview Question
Software Engineer / DevelopersThe volatile keyword indicates that the compiler should not optimize the code to eliminate this variable because it might modified from another file. Once such example is if you are reading from a spot in memory that another completely separate process or device may write to and you yourself are not changing the variable in your own code.
Volatile variables tells the compiler that this variable has the tendency to change so should not be optimized by putting such variables in cache.
- leoTheMaverick April 03, 2010Whenever this variable is accessed to retrieve its value.It has to be accecesed freshly,There are higher chances that this variable might have been changed by some other process or hardware