+ 1

Can someone explain where we use volatile in real time?

I know this when we use volatile with variable that means we are instructing a compiler to access a variable everytime form main memory. in simple words volatile avoids optimization of a variable.

28th Feb 2017, 9:59 AM
Venkata Subba Reddy Gowru
Venkata Subba Reddy Gowru - avatar
1 Antwort
+ 2
I believe the volatile modifier makes the variable to be read from memory before every arithmetics on it. Especially (and only tbh) useful in multi-threaded enviroment where two or more threads might read/write a variable at the same time.
5th Mar 2017, 12:59 PM
Norbivar
Norbivar - avatar