Is synchronized inherited in Java?

Yoda picture Yoda · Apr 14, 2013 · Viewed 7.6k times · Source

I have superclass Point and a synchronized method draw(). Will the subclasses of Point inherit synchronized if I override method draw() in them or I have to always write it?

Answer

Sebastian picture Sebastian · Apr 14, 2013

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).