Skip to content

Commit c8bf978

Browse files
committed
添加AQS ReentrantLock CountDownLatch
1 parent 2c696d3 commit c8bf978

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

  • Java-Learning-Summary/src/cn/edu/jxnu/concurrent

Java-Learning-Summary/src/cn/edu/jxnu/concurrent/AQS.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ PV操作的意义:我们用信号量及PV操作来实现进程的同步和互
4545
进程的互斥是指当有若干个进程都要使用某一共享资源时,任何时刻最多只允许一个进程去使用该资源,其他要使用它的进程必须等待,直到该资源的占用着释放了该资源。
4646
进程的同步是指在并发进程之间存在这一种制约关系,一个进程依赖另一个进程的消息,当一个进程没有得到另一个进程的消息时应等待,直到消息到达才被唤醒
4747

48+
ReentrantLock的定义:
49+
50+
```
51+
public class ReentrantLock implements Lock, java.io.Serializable { }
52+
```
4853

4954
ReentrantLock的lock方法:
5055

@@ -99,7 +104,6 @@ ReentrantLock的lock方法:
99104
看下FairSync的tryAcquire方法:
100105

101106
```
102-
@ReservedStackAccess
103107
protected final boolean tryAcquire(int acquires) {
104108
final Thread current = Thread.currentThread();
105109
int c = getState();
@@ -447,7 +451,11 @@ CountDownLatch的构造方法:
447451
this.sync = new Sync(count);
448452
}
449453
```
454+
CountDownLatch的定义:
450455

456+
```
457+
public class CountDownLatch { }
458+
```
451459
和ReentrantLock类似,CountDownLatch内部也有一个叫做Sync的内部类,同样也是用它继承了AQS。
452460

453461
再看下Sync类:

0 commit comments

Comments
 (0)