mirror of
https://github.com/Snailclimb/JavaGuide
synced 2025-06-16 18:10:13 +08:00
Merge pull request #2575 from Kisa-Dong/main
Update java-concurrent-questions-02.md
This commit is contained in:
commit
5533692b77
@ -530,13 +530,13 @@ public class SynchronizedDemo {
|
|||||||
|
|
||||||

|

|
||||||
|
|
||||||
对象锁的的拥有者线程才可以执行 `monitorexit` 指令来释放锁。在执行 `monitorexit` 指令后,将锁计数器设为 0,表明锁被释放,其他线程可以尝试获取锁。
|
对象锁的拥有者线程才可以执行 `monitorexit` 指令来释放锁。在执行 `monitorexit` 指令后,将锁计数器设为 0,表明锁被释放,其他线程可以尝试获取锁。
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
如果获取对象锁失败,那当前线程就要阻塞等待,直到锁被另外一个线程释放为止。
|
如果获取对象锁失败,那当前线程就要阻塞等待,直到锁被另外一个线程释放为止。
|
||||||
|
|
||||||
#### synchronized 修饰方法的的情况
|
#### synchronized 修饰方法的情况
|
||||||
|
|
||||||
```java
|
```java
|
||||||
public class SynchronizedDemo2 {
|
public class SynchronizedDemo2 {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user