獲取對象鎖的兩種方法: 1.同步代碼塊 synchronized (this) synchronized (類實(shí)例對象) 2.同步非靜態(tài)方法 synchronized void method() 獲取類鎖的兩種方法 1.同步代碼塊 synchronized(類.class) 2.同步靜態(tài)方法 synchronized static void method()