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阅读 2,669评论 0 0
  • 心随笔走 写一下上个月的总结吧,再次重新翻了一下9月的日记和8月的总结,本来打算不写总结的我又再次燃起写一下的冲动...
    光头熊大光头阅读 3,717评论 0 0
  • 啊嘎嘎嘎嘎
    看手机回电话阅读 1,430评论 0 1
  • 他们有恢复了以前的日子,互相照顾,互相关心,一次女孩的脚起了水泡,很疼很疼。男孩中午回去后借了钱,帮女孩买了拖鞋和...
    GEDD520阅读 1,046评论 0 0