my dog learned polymorphism
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
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’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link:
subject: Lock on Objects
It's not a secret anymore!