+ 4
What is volatile keyword?
5 Respuestas
+ 2
thanks all
+ 1
By declaring a variable volatile, you indicate that a variable's value will be modified by different threads. Incidentally, its value will never be cached thread-locally, and access to the variable acts as though it is enclosed in a synchronized block, synchronized on itself.
+ 1
Declaring a volatile java variable means: The value of this variables will never be cached thread-locally: all reads and writes will go straight to "main memory"; Access to the variableacts as though it is enclosed in a synchronized block, synchronized on itself.
+ 1
you all is collect
0
The count variable is declared as volatile. The copy of volatile variable is stored in the main m/r, so every time a thread access the variable even for reading purpose the local copy is updated each time from the main m/r. The volatile variable also have performance issues.