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).]
Joined: May 10, 2001
Hello, 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! Cheers, RL