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?
相关问题
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
- Difference between Types.INTEGER and Types.NULL in
You can check it yourself by writing this:
And test class
On my machine it was 137099 instead of 200000.
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).
your Overriden method will no longer be synchronized if you Override it and remove the
synchronized
. Found it here and here