java - synchronized修饰代码块括号后面锁失效?
PHPz
PHPz 2017-04-18 09:29:25
0
2
417
PHPz
PHPz

学习是最好的投资!

reply all(2)
Ty80

You can refer to my blog

The use of Synchronized for thread synchronization

Thread synchronization: Application of Synchronized in singleton mode

Peter_Zhu

This blog has the answer. However, the reference to global lock is easily misleading. Because sychoronized 是使用括号里的对象来上锁,而 String.class is not all instances of the String class, but an object, an object of type Class. Therefore, if you use different such class objects to synchronize, you will obtain different locks.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template