2017-03-13 Java多线程学习笔记-Doug Lea 谈 Synchronization and the Java Memory Model

Doug Lea 谈 Synchronization and the Java Memory Model

主要是讨论同步和Java内存模型之间的关系,讲的原理,从多线程处理产生的问题出发,引导出同步的三个需要处理的问题:原子性,可见性,顺序性。

Atomicity

Which instructions must have indivisible effects. For purposes of the model, these rules need to be stated only for simple reads and writes of memory cells representing fields - instance and static variables, also including array elements, but not including local variables inside methods.

Visibility

Under what conditions the effects of one thread are visible to another. The effects of interest here are writes to fields, as seen via reads of those fields.

Ordering

Under what conditions the effects of operations can appear out of order to any given thread. The main ordering issues surround reads and writes associated with sequences of assignment statements.

讲的特别棒,虽然英文吃力,但是有所得。

然后 Lea 还特别讲了下 Java 关键字 Volatile,用到的场景:

The field need not obey any invariants with respect to others.
Writes to the field do not depend on its current value.
No thread ever writes an illegal value with respect to intended semantics.
The actions of readers do not depend on values of other non-volatile fields.

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • **2014真题Directions:Read the following text. Choose the be...
    又是夜半惊坐起阅读 13,580评论 0 23
  • Given a string, determine if it is a palindrome, consider...
    exialym阅读 1,558评论 0 0
  • Whenever I encountered a grownup who seemed to me at all ...
    晨汐潮沙阅读 3,928评论 0 0
  • 芳兰独影怜,花事已荼靡。 离离风盈袖,脉脉雨隐溪。 美人芙蓉色,依稀残梦里。 终是落凡尘,归去任东西。
    落梅君阅读 2,600评论 0 2
  • 在黑夜里 伴随着“咯哒”一声 眼前的一切变的黑暗起来 恐惧并颤抖着身躯并大喊着 四处寻找着光线 哪怕只是一丝的亮光...
    脱度阅读 1,769评论 0 0

友情链接更多精彩内容