synchronized

What will happen to a static synchronized method?
Since static method is associated with a class, not an object.
So thread acquires intrinsic lock for the Class object associated with the class.

Access to class's static fields is controlled by a lock that is distinct from the lock for any instance of the class. -- by Java doc.

In a word, static fields in a class own a different lock from the instance of class.

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容

  • 代理和委托回調 模擬一個學生找槍手代考的用代理代理給我感覺像是 代理方和被代理方通過遵循同一個協議,以這個為橋梁,...
    theDeskmateOfSb閱讀 350評論 0 0
  • 心隨筆走 寫一下上個月的總結吧,再次重新翻了一下9月的日記和8月的總結,本來打算不寫總結的我又再次燃起寫一下的沖動...
    光頭熊大光頭閱讀 603評論 0 0
  • 啊嘎嘎嘎嘎
    看手機回電話閱讀 217評論 0 1
  • 他們有恢復了以前的日子,互相照顧,互相關心,一次女孩的腳起了水泡,很疼很疼。男孩中午回去后借了錢,幫女孩買了拖鞋和...
    GEDD520閱讀 155評論 0 0