Usually if a global variable is shared by more than one thread, this variable needs to be declared volatile. Basically I understand why we need to declare a variable as volatile because it may change without being detected by compiler. But what make a shared global variable change without being detected by compiler in a multithreaded environment?