How can the wait()
and notify()
methods be called on Objects that are not Threads? That doesn\'t really make sense, does it?
Surely, it mus
Think using a real life example, a washroom. When you want to use the washroom at your office, you have two options to make sure no one else will come to the washroom once you are using it.
Which option would you take?
Yes, it's the same in the Javaland!.
So in the above story,
So just like in real life, when you have some private business, you lock that object. And when you are done with that object, you let go of the lock!.
(Yes yes!, this is a very simple description on what happens. Of course the real concept is slightly different from this, but this is a starting point)