之前的部分都没有记录了,从这里开始,所看过的自己意识中并非理所当然的东西记录一下,以后再看看笔记就复习一遍。
4.5. Documenting Synchronization Policies
应该在文档中明确表明wether our class is thread safe,so our user or maintainer will be feel better.
Some library code like JDBC or Servlet framwork does not specific whether they are threadsafe, from a designer's perspective(not merely a user's), we can assume them does this, we can resonable assume,servlet must be designed to be accessed by multiple thread,otherwise it will be useless.
同样的道理DataSource.getConnection一般是线程安全的,但connection本身可能不适合被多线程同时使用。通常应用都有一个池来管理,或者把connection放到线程限制当中
5.1. Synchronized Collections
给已经线程安全的容器增加功能时,如vector,要用容器对象来做同步(容器对象本身作为自己内部同步的锁)
迭代的时候如果不同步并且迭代中被修改的话,是快速失败的,会抛出ConcurrentModificationException
注意隐式的迭代被调用,比如容器对象的toString调用时,会隐式迭代
synchronized collections 对所有的操作加锁,性能问题。
5.2. Concurrent Collections
在并发高性能,高scalability方面,是对Synchronized Collections的替代
The iterators returned by ConcurrentHashMap are weakly consistent instead of fail-fast.
CopyOnWriteArrayList在读取操作远远大于修改时非常适用,比如事件通知系统中的监听器列表。他在修改的时候会复制一个出来,而不修改原来的。
5.3. Blocking Queues and the Producer-consumer Pattern
One of the most common producer-consumer designs is a thread pool coupled with a work queue; this pattern is embodied in the Executor task execution framework that is the subject of Chapters 6 and 8.
分享到:
相关推荐
<<java并行编程>>英文版chm格式,英文名称<Java Concurrency in Practice>,一直想买这本书,但总是缺货,找到了电子版,分享给大家。 Java Concurrency in Practice By Brian Goetz, Tim Peierls, Joshua Bloch,...
Java Concurrency in Practice 英文无水印pdf pdf所有页面使用FoxitReader和PDF-XChangeViewer测试都可以打开 本资源转载自网络,如有侵权,请联系上传者或csdn删除 本资源转载自网络,如有侵权,请联系上传者...
Java Concurrency in practice
java concurrency in practice
Java concurrency in Practice高清pdf,带目录标签,Java并发实战
Java Concurrency in Practice源码
Java Concurrency in Practice JAVA并发编程实践中文版(全)第二部分
Using the concurrency building blocks in java.util.concurrent Performance optimization dos and don'ts Testing concurrent programs Advanced topics such as atomic variables, nonblocking algorithms, ...
正规PDF版本的 Java Concurrency In Practice。 经典著作,学习有益!
Concurrent_Programming+Java Concurrency in Practice+langspec
Java并发编程实践(Java Concurrency in Practice) (中英版)
Java.Concurrency.in.Practice.pdf
Many ofthe designations used bymanufacturersand ...appear in this book,and the publisher wasaware ofatrademark claim, the designations have been printed with initialcapitalletters or in all capitals.
java_concurrency_in_practice.pdf jcip-examples-src.jar jcip-annotations-src.jar 英文版是高清晰的,实战和实践都是同一帮人对英文版书的翻译,网传实战的翻译质量更好,实战是2012年出版的,应该是对前一版实践...
这本书很出名吧,大家都知道吧,我靠,20个字的描述咋这么累啊。
Java Concurrency in Practice