3 ms·
I think having both int as a value type and Integer as an object, etc. is defensible given what the original Java had to run on. The thing I never understand, h
by Someone 4y ago
I think having both int as a value type and Integer as an object, etc. is defensible given what the original Java had to run on. The thing I never understand, however, is why, at the same time, they went with a language that allows one to use synchronized on any object.
Because object allocation and the use of an allocated object in a synchronized part can be far away from each other both in time and in source code (quite possibly even in different jars), I would think that creates object overhead that’s hard to optimize away.
What would Java have lost if it required a synchronizable keyword on class definitions to allow callers to synchronize on instances of a class?