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

monitor and object lock

harish shankarnarayan
Ranch Hand

Joined: Sep 12, 2005
Posts: 158
wats aquring a monitor on object ,
and wats object locking .

can any one explain me confused.

Harish<br />SCJP 1.4 (85%)
Jim Yingst

Joined: Jan 30, 2000
Posts: 18671
"Acquiring a monitor", "locking an object", "acquiring a lock on an object", "synchronizing on an object" - those all mean the same thing, essentially. I'm not going to explain in detail, as I assume you have some book that you're learnign from. (If not, you can use Thinking In Java - chapter 14 talks about synchronization. If you have more specific questions about locking, you can post them here.

"I'm not back." - Bill Harding, Twister
vipul patel
Ranch Hand

Joined: Oct 16, 2005
Posts: 146
All objects in java have a lock. Another term for lock is monitor. All classes have lock too. so you have object level lock and class level lock.
When compiler encounters any code surrounded by 'synchronized' keyword, It means that it make sure that a thread would acquirer lock/monitor first before actually entering to "synchronized block".

This way threads synchronize with each other on shared data.

For more details: Pls refer Khalid Mughal's book on java.
I agree. Here's the link:
subject: monitor and object lock
jQuery in Action, 3rd edition