Skip to content

Commit

Permalink
Merge pull request #153 from crossoverJie/fix
Browse files Browse the repository at this point in the history
🐛 Fixing a bug. #149
  • Loading branch information
crossoverJie authored Mar 26, 2019
2 parents 3b510fb + ce62d15 commit c398353
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion MD/Synchronize.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public class com.crossoverjie.synchronize.Synchronize {
#### 释放锁
当有另外一个线程获取这个锁时,持有偏向锁的线程就会释放锁,释放时会等待全局安全点(这一时刻没有字节码运行),接着会暂停拥有偏向锁的线程,根据锁对象目前是否被锁来判定将对象头中的 `Mark Word` 设置为无锁或者是轻量锁状态。

偏向锁可以提高带有同步却没有竞争的程序性能,但如果程序中大多数锁都存在竞争时,那偏向锁就起不到太大作用。可以使用 `-XX:-userBiasedLocking=false` 来关闭偏向锁,并默认进入轻量锁。
偏向锁可以提高带有同步却没有竞争的程序性能,但如果程序中大多数锁都存在竞争时,那偏向锁就起不到太大作用。可以使用 `-XX:-UseBiasedLocking` 来关闭偏向锁,并默认进入轻量锁。


### 其他优化
Expand Down
2 changes: 1 addition & 1 deletion docs/thread/Synchronize.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public class com.crossoverjie.synchronize.Synchronize {
#### 释放锁
当有另外一个线程获取这个锁时,持有偏向锁的线程就会释放锁,释放时会等待全局安全点(这一时刻没有字节码运行),接着会暂停拥有偏向锁的线程,根据锁对象目前是否被锁来判定将对象头中的 `Mark Word` 设置为无锁或者是轻量锁状态。

偏向锁可以提高带有同步却没有竞争的程序性能,但如果程序中大多数锁都存在竞争时,那偏向锁就起不到太大作用。可以使用 `-XX:-userBiasedLocking=false` 来关闭偏向锁,并默认进入轻量锁。
偏向锁可以提高带有同步却没有竞争的程序性能,但如果程序中大多数锁都存在竞争时,那偏向锁就起不到太大作用。可以使用 `-XX:-UseBiasedLocking` 来关闭偏向锁,并默认进入轻量锁。


### 其他优化
Expand Down

0 comments on commit c398353

Please sign in to comment.