Java Concurrency (1)
Memory that can be shared betweenthreads is called shared memory or heap memory. The term variable as used inthis technical report refers to both fields and array elements. Variables thatare shared between threads are referred to as shared variables. All instance fields,static fields, and array elements are shared variables allocated in heapmemory. Local variables, formal method parameters, and exception-handlerparameters are never shared between threads and are not affected by the memorymodel.
The visibility of writes toshared variables can be problematic because the value of a shared variable maybe cached and not written to main memory immediately. Consequently, anotherthread may read a stale value of the variable.
A further concern is thatconcurrent executions of code are typically interleaved, and statements may bereordered b the compiler or runtime system to optimize performance. Thisresults in execution orders that are not immediately obvious when the sourcecode is examined. Failure to account for possible reordering is a common sourceof data races.
Volatile accesses do notguarantee the atomicity of composite operations such incrementing a variable.Consequently, volatile is not applicable in cases where the atomicity ofcomposite operations must be guaranteed.
A correctly synchronized programis one whose sequentially consistent executions do not have any data races.
Correct visibility guaranteesthat multiple threads accessing shared data can view each others’ results, butdoes not establish the order of when each thread reads or writes the data.Correct synchronization guarantees that threads access data in a proper order.
Java Concurrency (1)的更多相关文章
- Java Concurrency in Practice 读书笔记 第十章
粗略看完<Java Concurrency in Practice>这部书,确实是多线程/并发编程的一本好书.里面对各种并发的技术解释得比较透彻,虽然是面向Java的,但很多概念在其他语言 ...
- Java Concurrency - 浅析 CountDownLatch 的用法
The Java concurrency API provides a class that allows one or more threads to wait until a set of ope ...
- Java Concurrency - 浅析 CyclicBarrier 的用法
The Java concurrency API provides a synchronizing utility that allows the synchronization of two or ...
- Java Concurrency - 浅析 Phaser 的用法
One of the most complex and powerful functionalities offered by the Java concurrency API is the abil ...
- Java Concurrency - 线程执行器
Usually, when you develop a simple, concurrent-programming application in Java, you create some Runn ...
- Java Concurrency - Callable & Future
One of the advantages of the Executor framework is that you can run concurrent tasks that return a r ...
- 深入浅出 Java Concurrency (4): 原子操作 part 3 指令重排序与happens-before法则
转: http://www.blogjava.net/xylz/archive/2010/07/03/325168.html 在这个小结里面重点讨论原子操作的原理和设计思想. 由于在下一个章节中会谈到 ...
- 《Java Concurrency》读书笔记,使用JDK并发包构建程序
1. java.util.concurrent概述 JDK5.0以后的版本都引入了高级并发特性,大多数的特性在java.util.concurrent包中,是专门用于多线并发编程的,充分利用了现代多处 ...
- 深入浅出 Java Concurrency (15): 锁机制 part 10 锁的一些其它问题
主要谈谈锁的性能以及其它一些理论知识,内容主要的出处是<Java Concurrency in Practice>,结合自己的理解和实际应用对锁机制进行一个小小的总结. 首先需要强调的 ...
- 《深入浅出 Java Concurrency》——原子操作
part1 从AtomicInteger開始 从相对简单的Atomic入手(java.util.concurrent是基于Queue的并发包.而Queue.非常多情况下使用到了Atomic操作.因此首 ...
随机推荐
- 使用AndroidStudio快速开发教程
关于AndroidStudio的使用 参考:http://www.codes51.com/article/detail_98914.html 1.对于开发环境的通性:编写 调试 视图 一般的开发 ...
- Kafka集群在空载情况下Cpu消耗比较高的问题
线上kafka与storm的空载情况下负载都比较高, kafka达到122%, storm平均负载达到, 20%, 当前是通过Ambari下管理kafka的, a. 先停止s5的kafka进程.b. ...
- java之JAVA异常
异常的分类 1. 编译时被检测异常:只要是Exception和其子类都是,除了特殊子类RuntimeException体系. 此类异常在处理时必须进行声明或进行捕捉 这 ...
- 原生js写的一个弧形菜单插件
弧形菜单是一种半弧式或者全弧形菜单,是一种不同于传统横向或者竖向菜单形式的菜单.最近在网上看到好多人写出了这种效果,于是也尝试自己写了一个. 实现方式:原生态js 主要结构: 1.参数合并 var d ...
- NHibernate-Generator主键生成方式
NHibernate之Generator主键生成方式 (1) assigned主键由外部程序负责生成,无需NHibernate参与. (2) hilo通过hi/lo 算法实现的主键生成机制,需要额 ...
- 图解IntelliJ IDEA v13应用服务器的运行配置
初步了解IntelliJ IDEA v13应用服务器以后,接下来我们将继续设置应用服务器的运行配置. Artifacts是IDE在通过运行配置时部署的一个服务.Artifacts包括名称.类型.输出目 ...
- 安装Visual Studio 2010 - 初学者系列 - 学习者系列文章
本文讲述如何安装Visual Studio 2010开发工具. 首先,通过下列地址获取Visual Studio 2010的副本 1.开始页面 2.欢迎页 3.这里选择 自定义 ,选择安装路径 4.这 ...
- 谈Linux
新手谈Linux 目录: 什么是Linux? Linux与UNIX的区别 Linux与Windows比较 什么是Linux发布版? Linux应用领域 Linux版本的选择 怎么学习Linux? ...
- Linux Shell 示例精解(第七章 gawk编程)转载
第七章 gawk功能:gawk编程 7.1.1 数字和字符串常量 初始化和类型强制 在awk中,变量不需要定义就可以直接使用,使用一个变量就是对变量的定义.变量的类型可以试数字.字符串,或者 ...
- 使用UpdatePanel控件
使用UpdatePanel控件(二) UpdatePanel可以用来创建丰富的局部更新Web应用程序,它是ASP.NET 2.0 AJAX Extensions中很重要的一个控件,其强大之处在于不用编 ...