本月博客排行
-
第1名
龙儿筝 -
第2名
lerf -
第3名
fantaxy025025 - johnsmith9th
- zysnba
- xiangjie88
年度博客排行
-
第1名
青否云后端云 -
第2名
宏天软件 -
第3名
gashero - wy_19921005
- vipbooks
- benladeng5225
- e_e
- wallimn
- javashop
- ranbuijj
- fantaxy025025
- jickcai
- gengyun12
- zw7534313
- qepwqnp
- 解宜然
- ssydxa219
- zysnba
- sichunli_030
- sam123456gz
- arpenker
- 龙儿筝
- tanling8334
- kaizi1992
- gaojingsong
- xpenxpen
- jh108020
- wiseboyloves
- ganxueyun
- xyuma
- xiangjie88
- wangchen.ily
- Jameslyy
- luxurioust
- lemonhandsome
- jbosscn
- mengjichen
- zxq_2017
- lzyfn123
- nychen2000
- forestqqqq
- wjianwei666
- ajinn
- zhanjia
- Xeden
- hanbaohong
- java-007
- 喧嚣求静
- mwhgJava
- kingwell.leng
最新文章列表
Java Concurrency: Cancellation and Shutdown
Dealing well with failure, shutdown, and cancellation is one of the characteristics that distinguishes a well-behaved application from one that merely works.
1> Task Cancellation:
An act ...
Java Concurrency: JCIP Notes
1. Risks of Threads:
1> Safety Hazards
We can add annotation: @NotThreadSafe, @ThreadSafe, @Immutable
2> Liveness Hazards
Deadlock, Starvation, Livelock
...
Java Concurrency: Latches & Barriers
Latches:
A latch is a synchronizer that can delay the process of threads until it reaches its terminal state.
A latch acts as a gate: until the latch reaches the terminal state the gate is ...
Java Concurrency: ExecutorService Introduction
1) Difference between Callable and Runnable
The Callable interface is similar to Runnable, in that both are designed for classes whose instances are potentially executed by another thread. A Ru ...
可见性(visibility)的问题是Java多线程应用中的错误的根源
看下面一段代码,预想的输出结果为 42
public class NoVisibility {
private static boolean ready;
private static int number;
private static class ReaderThread extends Thread {
public void run() ...
synchronizer--JCIP5.5读书笔记
[本文是我对Java Concurrency In Practice 5.5的归纳和总结. 转载请注明作者和出处, 如有谬误, 欢迎在评论中指正. ]
Synchronizers
synchronizer是指那些根据状态协调线程的对象. BlockingQueue就是一个典型的synchronizer: 当队列为空时, 取数据的消费者线程将被阻塞, 直到队列不为空; 当队列满时, 存入数据 ...
使用BlockingQueue构建生产者消费者模式--JCIP5.3读书笔记
[本文是我对Java Concurrency In Practice 5.3的归纳和总结. 转载请注明作者和出处, 如有谬误, 欢迎在评论中指正. ]
生产者消费者模式
以缓冲区作为生产者和消费者之间沟通的桥梁: 生产者只负责生产, 将生产出来的数据存入缓冲区. 而消费者只负责消费, 不断的从缓冲区中取出数据进行处理.
生产者消费者模式是非常常用的, 因为应用该模式有效的解耦了生产者和消 ...
ConcurrentHashMap和CopyOnWriteArrayList--Java Concurrency In Practice C05读书笔记
[本文是我对Java Concurrency In Practice 5.2的归纳和总结. 转载请注明作者和出处, 如有谬误, 欢迎在评论中指正. ]
ConcurrentHashMap类
我们可以使用Collections.sy ...
线程安全的集合类--Java Concurrency In Practice C05读书笔记
[本文是我对Java Concurrency In Practice 5.1的归纳和总结. 转载请注明作者和出处, 如有谬误, 欢迎在评论中指正. ]
synchronized集合
java集合框架提供了多种synchronized集合, 比如Vector, HashTable, Collections的synchronizedXxx方法的返回值等.
synchronized集合是线程 ...
利用对象限制和委托构建线程安全的类--Java Concurrency In Practice C04读书笔记
[本文是我对Java Concurrency In Practice第三章的归纳和总结. 转载请注明作者和出处, 如有谬误, 欢迎在评论中指正. ]
设计线程安全的类需要考虑:
1. 确定组成对象状态的变量.
2. 确定约束对象状态的不变式.
3. 建立并发访问对象状态的规则.
后置条件: 由于某些变量的取值是有限制范围的, 改变状态变量之后需要检查改变后的状态是否合法. 后置 ...
变量可见性和volatile, this逃逸, 不可变对象, 以及安全公开--Java Concurrency In Practice C03读书笔记
[本文是我对Java Concurrency In Practice第三章的归纳和总结, 也有部分语句摘自周志明所著的"深入理解java虚拟机". 转载请注明作者和出处, 如有谬误, 欢迎在评论中指正. ]
线程安全包含2个方面: 原子性和可见性, java的同步机制都是围绕这2个方面来确保线程安全的.
可见性
理解可见性首先要清楚为什么多线程环境下会有可见性问 ...