synchronized同步三种使用方法

1.同步代码块 synchronized (对象){ //代码块 }上面的对象能够是任意对象,但必须为同一对象 2.同步函数 synchronized void method(){ //代码 }同步方法使用的同步对象为该方法所属类自己,即this 3.同步静态方法 synchronized static void method(){ //代码 }静态同步方法使用的锁是类的
相关文章
相关标签/搜索