Question d’entretien chez Elastic

How does volatile work?

Réponse à la question d'entretien

Utilisateur anonyme

22 juil. 2018

Volatile works by guaranty no reordering of reading and write operations will be done and all read and write operations will be done on the main memory, not CPU cache, thus ensuring that if a single thread is writing/read and others are only read they will all see the same value. This is applicable only when a single writer is used. If multiple threads change the same variable (memory) it is not guaranteed a consistent view of values.