GeeCON Prague 2014*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Synchronization and Locks Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Synchronization and Locks" Watch "Synchronization and Locks" New topic
Author

Synchronization and Locks

Buhi Mume
Greenhorn

Joined: Jul 16, 2006
Posts: 17
From Kathy & Bert Java 5 book, it states that each object has just one lock (page 707). What does this mean?

I am confused because the book continues saying that (page 709)
That gives you the ability to have more than one lock for code synchronization within a single object.


Help? Thank you.
Sujittt Tripathyrr
Ranch Hand

Joined: Jun 21, 2006
Posts: 96
Hi

I think the meaning is when you have multiple object which are accessing the same shared rsources but if the block is in synchronized then only one object is eligible for access.

Please coorect me if i am wrong.

Thanks
Poobhathy Kannan
Ranch Hand

Joined: May 26, 2004
Posts: 94
It�s like this

Think there is a room with a pad-lock. If you enter that room then u will lock that room so no one else can enter into there. Once you have released only, any other can get in.

The same applies to threads too.
Room is an Object... Pad-lock is the lock� and you and others are threads.


http://learnertobeginner.blogspot.com/
Buhi Mume
Greenhorn

Joined: Jul 16, 2006
Posts: 17
The room and padlock analogy explains that an object has one lock. But how about the following?
That gives you the ability to have more than one lock for code synchronization within a single object.
Tony Shivpershad
Greenhorn

Joined: Sep 27, 2005
Posts: 18
I agree with Buhi, the statements appear to be contradictory. I am confused as well.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Synchronization and Locks