博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Java Memory Model
阅读量:5315 次
发布时间:2019-06-14

本文共 1343 字,大约阅读时间需要 4 分钟。

JMM defines how threads interact through memory.It used to be somewhat unclear and unnecessarily limiting,and so was revised.

JSR133:Shared variables/Heap memory Memory that can be shared between threads is called shared or heap memory. All instance fields, static fields and array elements are stored in heap memory. We use the term variable to refer to both fields and array elements. Variables local to a method are never shared between threads and are unaffected by the memory model.
Multithreads cannot pass each other data for communication,they should use shared variables to do this.
Memory that can be shared between threads is called shared memory or heap memory.
even though the programmer authored code where a variable is first written and later read, the compiler might reorder the statements as long as it does not change the program semantics. WHY? It is quite common for processors and compilers to do this for performance optimization. As a result, a thread might not see the values it expects to see. This can result in hard to fix bugs in concurrent programs.

"Visibility""Ordering"

(1)read and load from main memory-->working memory
(2)execution: use and assign
(3)working memory refresh main memory:story and write
keyword:"synchronized""volatile""final"

转载于:https://www.cnblogs.com/jnuyao/archive/2013/02/25/2931880.html

你可能感兴趣的文章
crontab command not found
查看>>
记录-springMVC访问web-inf下文件问题+在jsp页面导入jquery插件路径不对问题
查看>>
对于C语言中数组名是指针的理解
查看>>
实验八 接口与实现接口的类
查看>>
mac OSx 安装 mysqlclient
查看>>
Scala for the Impatients---(10)Traits
查看>>
简单的姓名号码查询系统
查看>>
PostgreSQL 保留关键字添加方法之一,不带参数的函数
查看>>
你的博客可能被爬了
查看>>
赛前热手 (天梯赛暴力题)
查看>>
.net 冒泡排序示例
查看>>
Uva(10330)
查看>>
vlan学习
查看>>
R-Sys.time计算程序运行时间
查看>>
Java类模板
查看>>
【转贴】SAP HANA内存数据库详解
查看>>
二分查找BinarySearch(Java)
查看>>
两种应该掌握的排序方法--------1.shell Sort
查看>>
vuejs动态组件给子组件传递数据
查看>>
javascript constrator and prototype
查看>>