Meaningless Drivel is fun!
The moose likes Threads and Synchronization and the fly likes What exactly is the Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark "What exactly is the "monitor"" Watch "What exactly is the "monitor"" New topic

What exactly is the "monitor"

Joshua White
Ranch Hand

Joined: Jun 04, 2001
Posts: 97
Hello All,
I am beginning with threads. I have read about the monitor. I know that a thread wishing to execute a synhcronized method/block must enter the objects monitor. What exactly is the monitor? Where is it located?

[This message has been edited by Joshua White (edited June 05, 2001).]
Ryan Langley
Ranch Hand

Joined: May 10, 2001
Posts: 46
Monitoring and locking an object are essentially the same thing. I think of monitor as the process by which a thread determines if it can gain a lock on an object. In other words, you can use the lock variable as a way to monitor an object to see if it is available to your thread. The Object class has a lock instance variable. The lock variable is ignored by default for overhead reasons, but once the synchronized keyword is used it indicates that the object should now pay attention to the lock variable and use it for controlling access to it. Hope this helps!

I agree. Here's the link:
subject: What exactly is the "monitor"
It's not a secret anymore!