aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Synchronized and exceptions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Synchronized and exceptions" Watch "Synchronized and exceptions" New topic

Synchronized and exceptions

Chris Bicnal
Ranch Hand

Joined: Aug 17, 2005
Posts: 72
Hi everyone,

I've been out of the game for a while so wanted to run something by you all. Let's say we have the following code... that instance, what happens to the lock on the object object if a were to equal b?


Fernando Franzini
Ranch Hand

Joined: Jan 09, 2009
Posts: 484

The object will be released no matter how it by throw exception or by end of execution synchronized block.

Fernando Franzini - Java Blog
Chris Bicnal
Ranch Hand

Joined: Aug 17, 2005
Posts: 72
Good stuff, that's what I thought although I wanted to make sure!


I agree. Here's the link:
subject: Synchronized and exceptions
Similar Threads
Threading from seperate class
synchronizing on an arbitrary Class object
synchronized question
Synchronized blocks
About synchoronized code blocks in java