Why are wait
, notify
and notifyAll
methods placed in Object
, not in some separated class?
Note, this question is not about moving them to Thread
class, I just wonder why does they litter Object
, not some new Monitor
class.
I see the following shortcomings of that idea:
- We won't be able to use our for-other-purpose fields as monitors. But this seems to agree with principle of modularity.
- Synchronized methods will now require some hack with generated hidden fields (like in closures), as
this
and<MyClass>.class
become not valid monitors.
So we could move away 5 methods from every object with a little woe. Or not?