美文网首页
synchronized

synchronized

作者: ibyr | 来源:发表于2016-12-02 21:57 被阅读5次

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.

相关文章

网友评论

      本文标题:synchronized

      本文链接:https://www.haomeiwen.com/subject/eevqmttx.html