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 a volatile int in Java thread-safe?

Is a volatile int in Java thread-safe? That is, can it be safely read from and written to without locking?

java multithreading thread-safety volatile
Volatile Struct Semantics

Is it sufficient to declare an instance of a structure-typed variable as volatile (if its fields are accessed in re-entrant …

c struct volatile
When would I use const volatile, register volatile, static volatile in C++?

I am wondering about the different uses of the volatile keyword in combination with register, const and static keywords. I …

c++ static constants volatile
What does "volatile" mean in Java?

We use volatile in one of our projects to maintain the same copy of variable accessed by different threads. My …

java volatile java-memory-model
The need for volatile modifier in double checked locking in .NET

Multiple texts say that when implementing double-checked locking in .NET the field you are locking on should have volatile modifier …

c# singleton volatile
What is the point of making the singleton instance volatile while using double lock?

private volatile static Singleton uniqueInstance In a singleton when using double lock method for synchronization why is the single instance …

java singleton volatile thread-synchronization double-checked-locking
How do I Understand Read Memory Barriers and Volatile

Some languages provide a volatile modifier that is described as performing a "read memory barrier" prior to reading the memory …

multithreading volatile memory-barriers
C volatile variables and Cache Memory

Cache is controlled by cache hardware transparently to processor, so if we use volatile variables in C program, how is …

c computer-science volatile computer-architecture memorycache
When is it preferable to use volatile boolean in Java rather than AtomicBoolean?

I've looked at the other volatile vs. Atomicxxxx questions in SO (including this one) and have read the description of …

java concurrency atomic volatile
C++ volatile member functions

class MyClass { int x, y; void foo() volatile { // do stuff with x // do stuff with y } }; Do I need to …

c++ volatile member-functions