What is a monitor?- It can be considered as a building which contains a special room.
- The mechanism that Java uses to support synchronization is the monitor.
It supports two kind of thread synchronization.
1. Mutual exclusion 2. Cooperation
1. Mutual exclusion: - Supported in JVM via object block. - It enables multiple threads to independently work on shared data without interfering with each other.
2. Cooperation: - Supported in JVM via wait() and notify() methods of class objects. - It enables threads to work together towards a common goal.
|