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

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Lock on Objects" Watch "Lock on Objects" New topic

Lock on Objects

Seth Anshul

Joined: May 02, 2006
Posts: 16
Why does each Object in Java has a corresponding lock?
Kaydell Leavitt
Ranch Hand

Joined: Nov 18, 2006
Posts: 689

The lock field in the Object class is for multi-threaded programming. Using an object's lock is sometimes necessary to keep data from becoming corrupted when there are multiple threads sharing the same objects.

I consider multi-threading to be a fairly advanced aspect of Java.
[ February 19, 2008: Message edited by: Kaydell Leavitt ]
Seth Anshul

Joined: May 02, 2006
Posts: 16
Thanks Kaydell.

Ulf, multiple post was not the intention.My net connection broke, thus leading to it.

Asset :roll:
I agree. Here's the link:
subject: Lock on Objects
It's not a secret anymore!