wood burning stoves*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes What does monitor mean? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "What does monitor mean?" Watch "What does monitor mean?" New topic
Author

What does monitor mean?

d jones
Ranch Hand

Joined: Mar 13, 2006
Posts: 76
Hi,

I came across the following statement "To call notify a thread must own the monitor lock."

What exactly does "monitor" mean? I have seen it used in a few articles but I'm not sure what it means.

Thanks
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42356
    
  64
Wikipedia is your friend: Monitor


Ping & DNS - my free Android networking tools app
Rancy Chadha
Ranch Hand

Joined: Jul 12, 2006
Posts: 135
Hi,

The word "monitor" in Java refers to obtaining LOCK on an object.
If you know a little about threads in java. This concept of monitor is related to threads.
Every object has its own lock or you can say every object has its own monitor.
This lock comes into a major use when we use synchronized methods/block.
Once a thread enters a synchronized method/block it automatically gets a lock on the current
object or instance of class. And how does this help?
Obtaining lock will ensure that no other thread will be able to use that object until this thread
releases the lock. So any modification done to the state of Object can be done only by the current
thread who has the lock and no other thread can simultaneously make changes to the state of the object.
I hope this clears it.

But you will understand it better after you read SYNCRONIZED CODE section of K&B book.

Thanks,
Rancy


Thanks,<br />-Rancy
 
 
subject: What does monitor mean?