Skip to content

Commit a3d23aa

Browse files
committed
md
1 parent 0ee47c4 commit a3d23aa

File tree

1 file changed

+16
-18
lines changed

1 file changed

+16
-18
lines changed

README.md

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -39,20 +39,18 @@ WeChat:Zed-RD [![Build Status](https://travis-ci.org/Fadezed/concurrency.svg?br
3939

4040

4141
## 缓存导致的可见性问题
42-
4342
* 一个线程对共享变量的修改,另外一个线程能够立刻看到,我们称为**可见性**
44-
* [代码示例](https://github.com/Fadezed/concurrency/blob/master/src/main/java/com/example/concurrency/visibility/Visibility.java)
43+
* [代码示例](https://github.com/Fadezed/concurrency/blob/master/src/main/java/com/example/concurrency/features/visibility/Visibility.java)
4544
![单核CPU](media/15603316282468/a07e8182819e2b260ce85b2167d446da.png)
4645
![多核CPU](media/15603316282468/e2aa76928b2bc135e08e7590ca36e0ea.png)
4746

4847

4948
## 线程切换带来的原子性问题
5049
* 一个或者多个操作在 CPU 执行的过程中不被中断的特性称为**原子性**
51-
5250
* **时间片**概念
5351
* 线程切换 ---〉提升cpu利用率。 tips:Unix系统因支持多进程分时复用而出名。
54-
* 线程切换[代码示例](https://github.com/Fadezed/concurrency/blob/master/src/main/java/com/example/concurrency/contentSwitch/ContentSwitchTest.java)
55-
* 原子问题[代码示例](https://github.com/Fadezed/concurrency/blob/master/src/main/java/com/example/concurrency/atomic/AtomicCounter.java)
52+
* 线程切换[代码示例](https://github.com/Fadezed/concurrency/blob/master/src/main/java/com/example/concurrency/features/contentswitch/ContentSwitchTest.java)
53+
* 原子问题[代码示例](https://github.com/Fadezed/concurrency/blob/master/src/main/java/com/example/concurrency/features/atomic/AtomicCounter.java)
5654

5755
![254b129b145d80e9bb74123d6e620efb](media/15603316282468/254b129b145d80e9bb74123d6e620efb.png)
5856
* count+=1 操作分析
@@ -94,7 +92,7 @@ public class Singleton {
9492
## 按需禁用缓存以及编译优化 [代码来源](http://www.cs.umd.edu/~pugh/java/memoryModel/jsr-133-faq.html)
9593

9694
* ## volatile
97-
* [代码示例](https://github.com/Fadezed/concurrency/blob/master/src/main/java/com/example/concurrency/volatileExample/VolatileExample.java)
95+
* [代码示例](https://github.com/Fadezed/concurrency/blob/master/src/main/java/com/example/concurrency/features/volatilecase/VolatileExample.java)
9896

9997
* ## synchronized
10098

@@ -134,9 +132,9 @@ public class Singleton {
134132
* 偏向锁
135133
* 轻量级锁
136134
* 重量级锁
137-
138135
139-
* [代码示例](https://github.com/Fadezed/concurrency/blob/master/src/main/java/com/example/concurrency/synchronizedEx/SynchronizedExample.java)
136+
137+
* [代码示例](https://github.com/Fadezed/concurrency/blob/master/src/main/java/com/example/concurrency/features/synchronizedcase/SynchronizedExample.java)
140138
141139
```
142140
class X {
@@ -158,7 +156,7 @@ public class Singleton {
158156
159157
## final
160158
161-
* [代码示例](https://github.com/Fadezed/concurrency/blob/master/src/main/java/com/example/concurrency/finalEx/FinalExample.java)
159+
* [代码示例](https://github.com/Fadezed/concurrency/blob/master/src/main/java/com/example/concurrency/features/finalcase/FinalExample.java)
162160
* 修饰变量时,初衷是告诉编译器:这个变量生而不变,非immutable,即只能表示对象引用不能被赋值(例如List);
163161
* 修饰方法则方法不能被重写
164162
* 修饰类则不能被扩展继承。
@@ -238,7 +236,7 @@ public class Singleton {
238236
239237
-------
240238
# 4.JAVA线程的生命周期
241-
* [代码示例](https://github.com/Fadezed/concurrency/blob/master/src/main/java/com/example/concurrency/threadState/ThreadState.java)
239+
* [代码示例](https://github.com/Fadezed/concurrency/blob/master/src/main/java/com/example/concurrency/features/threadstate/ThreadState.java)
242240
243241
## 通用的线程生命周期
244242
* 初始状态
@@ -484,7 +482,7 @@ class Semaphore{
484482
### 使用方法
485483
#### 实现互斥
486484
#### 实现限流器(Semaphore 可以允许多个线程访问一个临界区)
487-
* [代码示例](https://github.com/Fadezed/concurrency/blob/master/src/main/java/com/example/concurrency/semaphore/SemaphoreEx.java)
485+
* [代码示例](https://github.com/Fadezed/concurrency/blob/master/src/main/java/com/example/concurrency/features/semaphore/SemaphoreEx.java)
488486
489487
490488
-------
@@ -495,16 +493,16 @@ class Semaphore{
495493
* 只允许一个线程写共享变量
496494
* 如果一个写线程正在执行写操作,此时禁止读线程读共享变量
497495
498-
* [代码示例](https://github.com/Fadezed/concurrency/blob/master/src/main/java/com/example/concurrency/readWriteLock/CacheByReadWriteLock.java)
496+
* [代码示例](https://github.com/Fadezed/concurrency/blob/master/src/main/java/com/example/concurrency/features/readwritelock/CacheByReadWriteLock.java)
499497
500498
## StampedLock 加上乐观读(无锁)
501-
* [代码示例](https://github.com/Fadezed/concurrency/blob/master/src/main/java/com/example/concurrency/readWriteLock/StampedLockEx.java)
499+
* [代码示例](https://github.com/Fadezed/concurrency/blob/master/src/main/java/com/example/concurrency/features/readwritelock/StampedLockEx.java)
502500
503501
## CountDownLatch
504-
* [代码示例](https://github.com/Fadezed/concurrency/blob/master/src/main/java/com/example/concurrency/countDownLatchEx/CountDownLatchEx.java)
502+
* [代码示例](https://github.com/Fadezed/concurrency/blob/master/src/main/java/com/example/concurrency/features/countdownlatch/CountDownLatchEx.java)
505503
506504
## CyclicBarrier
507-
* [代码示例](https://github.com/Fadezed/concurrency/blob/master/src/main/java/com/example/concurrency/cyclicBarrierEx/CyclicBarrierEx.java)
505+
* [代码示例](https://github.com/Fadezed/concurrency/blob/master/src/main/java/com/example/concurrency/features/cyclicbarrier/CyclicBarrierEx.java)
508506
509507
510508
@@ -581,7 +579,7 @@ CopyOnWriteArraySet、ConcurrentSkipListSet
581579
# 11. 原子类
582580
583581
* 无锁方案实现原理(Compare And Swap)
584-
* [代码示例](https://github.com/Fadezed/concurrency/blob/master/src/main/java/com/example/concurrency/atomic/SimulatedCAS.java)
582+
* [代码示例](https://github.com/Fadezed/concurrency/blob/master/src/main/java/com/example/concurrency/features/atomic/SimulatedCompareAndSwap.java)
585583
* 概览图
586584
![atomi](media/15608379390765/atomic.png)
587585
@@ -640,7 +638,7 @@ accumulateAndGet(x,func)
640638
* 而创建一个线程,却需要调用操作系统内核的 API,然后操作系统要为线程分配一系列的资源,这个成本就很高了。
641639
642640
## 线程池是一种生产者-消费者模式(非一般意义池化资源)
643-
* [代码示例](https://github.com/Fadezed/concurrency/blob/master/src/main/java/com/example/concurrency/threadPool/MyThreadPool.java)
641+
* [代码示例](https://github.com/Fadezed/concurrency/blob/master/src/main/java/com/example/concurrency/features/threadPool/MyThreadPool.java)
644642
* Java ThreadPoolExecutor
645643
646644
```
@@ -713,7 +711,7 @@ get(long timeout, TimeUnit unit);
713711
714712
715713
## FutureTask工具类(实现了RunnableFuture而它继承了Runnable和Future接口)
716-
* [代码示例](https://github.com/Fadezed/concurrency/blob/master/src/main/java/com/example/concurrency/futureTask/FutureTaskEx.java)
714+
* [代码示例](https://github.com/Fadezed/concurrency/blob/master/src/main/java/com/example/concurrency/features/futuretask/FutureTaskEx.java)
717715
* 构造函数类似线程池submit
718716
719717
```

0 commit comments

Comments
 (0)