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操作.因此首 ...
随机推荐
- java设计模式之六适配器模式(Adapter)
适配器模式将某个类的接口转换成客户端期望的另一个接口表示,目的是消除由于接口不匹配所造成的类的兼容性问题.主要分为三类:类的适配器模式.对象的适配器模式.接口的适配器模式.首先,我们来看看类的适配器模 ...
- 我的时间,GTD做主
可能每一次总结的时候,我们都在努力的回顾,我这几天都干了什么,结果回顾半天得到的结果就是:我也不知道,仿佛什么都没有做似的.事实上不然,你已经做了好多事,但却始终有这样的感觉,有的时候都在自己发问:我 ...
- InstallShield集成安装MSDE2000最小版本(二) fishout特许授权发布
原文:InstallShield集成安装MSDE2000最小版本(二) fishout特许授权发布 原帖地址:http://blog.csdn.net/fishout/archive/2009/10/ ...
- 快速构建Windows 8风格应用24-App Bar构建
原文:快速构建Windows 8风格应用24-App Bar构建 本篇博文主要介绍构建AppBar基本步骤.如何构建AppBar.如何在AppBar中构建上下文命令.如何在AppBar中构建菜单.如何 ...
- SQL SERVER 2005中如何获取日期(一个月的最后一日、上个月第一天、最后一天、一年的第一日等等)
原文:[转]SQL SERVER 2005中如何获取日期(一个月的最后一日.上个月第一天.最后一天.一年的第一日等等) 在网上找到的一篇文章,相当不错哦O(∩_∩)O~ //C#本周第一天 ...
- Grub启动配置文件
和许多其他linux发行版一样,Fedora使用Grub作为32位和64位X86系统的启动加载器(bootloader).grub的配置文件主要是/boot/grub/grub.conf,而/boot ...
- leetcode 第43题 Wildcard Matching
题目:(这题好难.题目意思类似于第十题,只是这里的*就是可以匹配任意长度串,也就是第十题的‘.*’)'?' Matches any single character. '*' Matches any ...
- win7 64位的apache2.4.9+php5.5+mysql5.6的安装
Win7 下64位的apache2.4.9+php5.5+mysql5.6.19的安装 1.首先下载文件 httpd-2.4.9-win64-VC11.zip(http://www.apachelou ...
- Android项目----dispathTouchEvent
说到dispathTouchEvent,就不得不说一个最贱的屏幕触摸动作触发的一些列Touch事件: ACTION_DOWN->ACTION_MOVE->ACTION_MOVE->A ...
- java编程思想笔记(第一章)
Alan Kay 第一个定义了面向对象的语言 1.万物皆对象 2.程序是对象的集合,他们彼此通过发送消息来调用对方. 3.每个对象都拥有由其他对象所构成的存储 4.每个对象都拥有其类型(TYpe) 5 ...