Is synchronized inherited in Java?

后端 未结 3 1205
迷失自我
迷失自我 2020-12-03 02:29

I have superclass Point and a synchronized method draw(). Will the subclasses of Point inherit synchronized

3条回答
  •  北海茫月
    2020-12-03 03:09

    No, you will always have to write synchronized. If you call the synchronized method of the super class this will of course be a synchronized call. synchronized is not part of the method signature.

    See http://gee.cs.oswego.edu/dl/cpj/mechanics.html for detailed description from Doug Lea, Java threading boss (or so).

提交回复
热议问题