Skip to content

Commit 8e3b9eb

Browse files
authored
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.
1 parent b1c2dbe commit 8e3b9eb

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

docs/java/concurrent/aqs.md

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

0 commit comments

Comments
 (0)