This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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 Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "What does monitor mean?" Watch "What does monitor mean?" New topic

What does monitor mean?

d jones
Ranch Hand

Joined: Mar 13, 2006
Posts: 76

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.

Ulf Dittmer

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

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

Joined: Jul 12, 2006
Posts: 135

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,<br />-Rancy
Consider Paul's rocket mass heater.
subject: What does monitor mean?
Similar Threads
Progress bar within dialog box
What is a Monitor in thread ?
Tomcat Monitor error
Proper technique for special characters