wood burning stoves 2.0*
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
Author

Lock on Objects

Seth Anshul
Greenhorn

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.

http://java.sun.com/docs/books/jls/second_edition/html/memory.doc.html
[ February 19, 2008: Message edited by: Kaydell Leavitt ]
Seth Anshul
Greenhorn

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:
 
Don't get me started about those stupid light bulbs.
 
subject: Lock on Objects