Friday, 22 April 2016

Why thread communication methods wait(), notify() and notifyAll() are in Object class ?


In Java, every Object has a monitor and wait, notify methods are used to wait for the Object monitor or to notify other threads that Object monitor is free now.

There is no monitor on threads in java and synchronization can be used with any Object.

So every class in java has these essential methods for inter-thread communication.

No comments:

Post a Comment

Note: only a member of this blog may post a comment.