Merge branch 'master' of github.com:heibaiying/Full-Stack-Notes
This commit is contained in:
commit
7af2c30ac8
@ -576,7 +576,7 @@ public class J4_SynchronizedSafe {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
for (int j = 0; j < 100000; j++) {
|
for (int j = 0; j < 100000; j++) {
|
||||||
// 虽然调用的是不同的 IncreaseTask() 示例,但锁住的仍然是同一个对象,此时也是线程安全的
|
// 虽然调用的是不同的 IncreaseTask() 实例,但锁住的仍然是同一个对象,此时也是线程安全的
|
||||||
synchronized (s) {
|
synchronized (s) {
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user