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:
parent
b1c2dbed63
commit
8e3b9eb705
@ -209,7 +209,7 @@ final boolean nonfairTryAcquire(int acquires) {
|
||||
```java
|
||||
protected boolean tryAcquire(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 isHeldExclusively()//该线程是否正在独占资源。只有用到condition才需要去实现它。
|
||||
```
|
||||
|
Loading…
x
Reference in New Issue
Block a user