File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Lock on Objects Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Reply locked New topic

Lock on Objects

Seth Anshul

Joined: May 02, 2006
Posts: 16
Why does each Object in Java has a corresponding lock?
What is the utility of having such a functionality.
Amit Y Desai
Ranch Hand

Joined: Dec 06, 2007
Posts: 35
Well..locks are used to obtain lock on any object.As simple as that...

seee when multiple threads are working on a single object and you want to synchronize then each thread should obtain lock on object before operating...
it is same as monitor concept in operating systems...
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42956

please don't post the same question multiple times. If you need to edit a post, click the little paper-and-pencil icon ().

Let's continue the discussion in this duplicate post.
I agree. Here's the link:
subject: Lock on Objects
It's not a secret anymore!