When a multi-threaded program is running, and there is some common variable that is not declared as volatile, then these threads create a local copy of the variable and work with the local copy instead. Thus, changes to the variable are not reflected. This local copy is created because access to cached memory is much faster compared to accessing variables from main memory.
When you declare a variable as volatile, it tells the program NOT to create any local copy of the variable and use the variable directly from main memory.
volatile, , , , , .
, volatile , volatile, , . , , .