锁的等级:方法锁,对象锁,类锁.

synchronized()

同步普通方法,锁的是当前对象。

同步静态方法,锁的是当前 Class 对象。

同步块,锁的是 () 中的对象

Last updated