+ 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.
1 Resposta
+ 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.