Some threading problems were solved without extending java.lang.Object
.
The methods wait()
, notify()
and notifyAll()
are implemented on Object
, which seems to me not to be the best decision since it pollutes the class's interface. It affects all classes in Java, which I think should have been avoided.
Next, the synchronized
block takes an instance of type Object
, allowing us to accidently pass shared instances (e.g. String
), which can cause problems. They could have crafted a class Mutex
/Lock
in order to avoid this.
I wonder whether this comes with any technical advantages - e.g. performance - or whether it is just bad design? Is there somewhere an official documentation, e.g. a JEP or something similar - on why the Java language designers decided to work directly with java.lang.Object
?