Would it have been bad if, instead of synchronized keyword we had @Synchronized annotation? Would an annotation be more natural in this case (because you can override a synchronized method with a non-synchronized method – thus synchronized says nothing about the method itself but rather specifies something in addition to the method (that the method is guarded in a certain way), so it’s not really a keyword?)
Would it have been bad if, instead of synchronized keyword we had @Synchronized annotation?
Share
Synchronized transforms practically directly into monitorenter/monitorexit on the byte code level. And you specify what to synchronized on, you can’t do that with an annotation:
So it makes perfect sense to me that it is a keyword.