Top "Volatile" questions

Volatile is a qualifier used to define a data storage area (object, field, variable, parameter) that "can change on its own", thus disallowing some code generator optimizations.

Is this (volatile bool) always thread safe?

I'm wondering if this is completely thread-safe and whether or not the volatile keyword should be in place. using System.…

c# thread-safety volatile
Illustrating usage of the volatile keyword in C#

I would like to code a little program which visually illustrates the behavior of the volatile keyword. Ideally, it should …

c# .net volatile
How to declare array elements volatile in Java?

Is there a way to declare array elements volatile in Java? I.e. volatile int[] a = new int[10]; declares the …

java arrays concurrency volatile
Volatile in C++11

In C++11 standard the machine model changed from a single thread machine to a multi threaded machine. Does this mean …

c++ c++11 volatile
Does the C++ volatile keyword introduce a memory fence?

I understand that volatile informs the compiler that the value may be changed, but in order to accomplish this functionality, …

c++ multithreading c++11 volatile
C: Volatile Arrays in C

The volatile keyword is used in C to prevent the compiler performing certain optimizations, amongst other subtle changes, on a …

c++ c arrays embedded volatile
Can a pointer be volatile?

Consider the following code: int square(volatile int *p) { return *p * *p; } Now, the volatile keyword indicates that the value …

c++ pointers volatile
Volatile keyword in Java - Clarification

I am really confused about what I read about the applications of volatile keyword in java. Is the following statement …

java volatile
Using volatile keyword with mutable object

In Java, I understand that volatile keyword provides visibility to variables. The question is, if a variable is a reference …

java concurrency volatile mutable
What kinds of optimizations does 'volatile' prevent in C++?

I was looking up the keyword volatile and what it's for, and the answer I got was pretty much: It's …

c++ optimization volatile