Yes, this is allowed, because it does not change the contract, but implements it.
Think that you can always just add a synchronized block:
synchronized(this) {
only at the beginning of a method that will achieve roughly the same result. There may also be other (possibly hidden) locks in the method, which makes this really part of the implementation, not the API.
Denys seguret
source share