Java language provides a weak synchronization mechanism, namely the volatile variables, to ensure that the variable update inform other threads, volatile variables have variable visibility, prohibit reorder two properties, volatile variables will not be cached in a register or on other processors are not visible, so when reading a volatile type of the variable will always return the value of the latest write,
Two characteristics of volatile variables:
variable visibility
Guarantee that the variable is visible to all threads, in this case, the visibility is when one thread to modify the value of a variable, so the new value for other threads can immediately gain,
prohibited reorder
CodePudding user response:
The building Lord long-winded here, want to learn Java beginners or medium technology can be played to ding Wolf search some free courses to learn, learning is endless!CodePudding user response:
Thanks for share the Wolf elder brother