This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
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).]
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