Hello ,
I am reading threads and was having questions on term"Every Object has a monitor".After googling i undertood this.
There are multiple ways we can achieve concurrency
1)Semaphore
2)Monitors
3)Message Passing
In order to protect shared resources from multiple Threads
Java uses Monitor Model.
In Monitor model of concurrent programming ,Monitor encapsulates shared data and operation that operate on it and thus behaves as a data type, and
Monitor=MUTEX+CO-ORDNATION.
When compared with Java Object Oriented Language,MUTEX is acived by using synchronized keyword with method and CO-ORDNATION with wait-notify.
In java since a class encapuslates data and methods that operates on data and when we compare this with MOnitor model,every object of the class if it has synchronized method acts as Monitor.
And becuase of this JVM differentiates between normal objects and MOnitor Objects and thus apply locks correpsondingly.
Is my understanding correct?