1
0
mirror of https://github.com/Snailclimb/JavaGuide synced 2025-06-16 18:10:13 +08:00

Update aqs.md

Returns:
a negative value on failure; zero if acquisition in shared mode succeeded but no subsequent shared-mode acquire can succeed; and a positive value if acquisition in shared mode succeeded and subsequent shared-mode acquires might also succeed, in which case a subsequent waiting thread must check availability. (Support for three different return values enables this method to be used in contexts where acquires only sometimes act exclusively.) Upon success, this object has been acquired.
This commit is contained in:
Mr.Mi 2022-06-27 18:06:56 +08:00 committed by GitHub
parent b1c2dbed63
commit 8e3b9eb705
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -209,7 +209,7 @@ final boolean nonfairTryAcquire(int acquires) {
```java ```java
protected boolean tryAcquire(int)//独占方式。尝试获取资源成功则返回true失败则返回false。 protected boolean tryAcquire(int)//独占方式。尝试获取资源成功则返回true失败则返回false。
protected boolean tryRelease(int)//独占方式。尝试释放资源成功则返回true失败则返回false。 protected boolean tryRelease(int)//独占方式。尝试释放资源成功则返回true失败则返回false。
protected boolean tryAcquireShared(int)//共享方式。尝试获取资源。负数表示失败0表示成功但没有剩余可用资源正数表示成功且有剩余资源。 protected int tryAcquireShared(int)//共享方式。尝试获取资源。负数表示失败0表示成功但没有剩余可用资源正数表示成功且有剩余资源。
protected boolean tryReleaseShared(int)//共享方式。尝试释放资源成功则返回true失败则返回false。 protected boolean tryReleaseShared(int)//共享方式。尝试释放资源成功则返回true失败则返回false。
protected boolean isHeldExclusively()//该线程是否正在独占资源。只有用到condition才需要去实现它。 protected boolean isHeldExclusively()//该线程是否正在独占资源。只有用到condition才需要去实现它。
``` ```