Visibility between threads in concurrent programming

Know the JMM model

Each thread's operation on the shared variable of the main memory is that each thread is copied to its own working memory for operation and then written back to the main memory.

 

This may exist when the thread AAA modified the value of the shared variable x but has not yet written it back to the main memory, another thread BBB has operated on the shared variable x in the main memory, but the shared variable pair in the AAA thread working memory BBB thread is not visible.

This delay in the synchronization of working memory and main memory causes visibility problems.

Guess you like

Origin www.cnblogs.com/chuzhong/p/12731551.html
Recommended