Skip to content

Commit cad4be9

Browse files
committed
update readme
1 parent 6f9e320 commit cad4be9

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
fucking-java-concurrency
22
==========================
33

4-
:point_right: 通过Demo演示出`Java`中并发问题。
5-
6-
可以观察到的实际现象 :see_no_evil: 比 说说的并发原则 :speak_no_evil: 更直观更可信
4+
:point_right: 通过Demo演示出`Java`中并发问题。
5+
可以观察到的实际现象 :see_no_evil: 比 说说的并发原则 :speak_no_evil: 更直观更可信。
6+
\# 这里给Demo没有解释和讨论,可以参见[并发方面的系统的资料](ConcurrencyMaterial.md)
77

88
:beer: 无同步的修改在另一个线程中读不到
99
----------------------------------

src/main/java/com/oldratlee/fucking/concurrency/NoPublishDemo.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ private class ConcurrencyCheckTask implements Runnable {
3434
public void run() {
3535
System.out.println("ConcurrencyCheckTask started!");
3636
// 如果主线中stop的值可见,则循环会退出。
37-
// 在我的开发机上,几乎必现循环不退出!(解法:在running属性上加上volatile)
37+
// 在我的开发机上,几乎必现循环不退出!(简单安全的解法:在running属性上加上volatile)
3838
while (!stop) {
3939
}
4040
System.out.println("ConcurrencyCheckTask stopped!");

src/main/java/com/oldratlee/fucking/concurrency/WrongCounterDemo.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public static void main(String[] args) throws Exception {
2222

2323
int finalCounter = demo.counter;
2424
if (finalCounter != INC_COUNT * 2) {
25-
// 在我的开发机上,几乎必现!即使counter上加了volatile。
25+
// 在我的开发机上,几乎必现!即使counter上加了volatile。(简单安全的解法:使用AtomicInteger)
2626
System.err.printf("Fuck! Got wrong count!! expected: %s, actual %s", INC_COUNT * 2, finalCounter);
2727
} else {
2828
System.out.println("Wow... Got right count!");

0 commit comments

Comments
 (0)