I was reading through The Java Programming Language, Fourth Edition, and came across some confusing statements on synchronization in the "Threads" chapter. The information is as follows:
The way that synchronization is enforced in a class is an implementation detail. The fact that it is enforced is an important part of the contract of the class and must be clearly documented--the precense of the
synchronizedmodifier on a method might only be an implementation detail of the class, not part of a binding contract.
Correct me if I'm wrong, but it makes sense to me that there could be an un-synchronized method that is then overloaded in a subclass's implementation of that method such that it is synchronized.
However...
If a class's method is declared synchronized, can that method be overridden (or is it overloading in this case?) in a subclass such that it is the exact same but without a synchronized clause? If not, are there any ways to override/overload a method in a subclass such that it is not synchronized when the superclasses implementation is?
synchronizedis or is not a heritable method attribute. It's implied though by the examples in 8.4.3.6 which proclaim that a synchronized method "has exactly the same effect as" a method whose entire body is a single synchronized block. Method bodies obviously are not inherited.