I read some articles about the volatile keyword but I could not figure out its correct usage. Could you please tell me what it should be used for in C# and in
The volatile keyword has different meanings in both Java and C#.
From the Java Language Spec :
A field may be declared volatile, in which case the Java memory model ensures that all threads see a consistent value for the variable.
From the C# Reference on the volatile keyword:
The volatile keyword indicates that a field can be modified in the program by something such as the operating system, the hardware, or a concurrently executing thread.