Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

java并发 可见性定义 #765

Open
SuperJiang1998 opened this issue Aug 11, 2019 · 0 comments
Open

java并发 可见性定义 #765

SuperJiang1998 opened this issue Aug 11, 2019 · 0 comments
Labels

Comments

@SuperJiang1998
Copy link

可见性指当一个线程修改了共享变量的值,其它线程能够立即得知这个修改。Java 内存模型是通过在变量修改后将新值同步回主内存,在变量读取前从主内存刷新变量值来实现可见性的。

这一段,在缓存一致性协议这样定义的:
在多处理器下,为零保证各个处理器的缓存是一致的,每个处理器都会通过嗅探在总线上传播的数据来检查自己缓存的值是不是过期了。当处理器发现自己缓存行对应的地址被修改,就会将当前处理器的缓存行设置为无效状态。当处理器对这个数据进行读写的时候,会重新把数据从内存中读取到处理器缓存中。

应该说刷新内存之后,会使得其他cpu缓存失效,然后其他cpu读取的时候发现缓存失效了就重新读取内存中的数据。

@CyC2018 CyC2018 added the todo label Oct 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants