This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Synchronized and exceptions" Watch "Synchronized and exceptions" New topic
Author

Synchronized and exceptions

Chris Bicnal
Ranch Hand

Joined: Aug 17, 2005
Posts: 78
    
    1
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...




..in that instance, what happens to the lock on the object object if a were to equal b?

Thanks,

Chris
Fernando Franzini
Ranch Hand

Joined: Jan 09, 2009
Posts: 486
    
    2

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


Fernando Franzini - Java Blog
Chris Bicnal
Ranch Hand

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

Thanks!

Chris
 
 
subject: Synchronized and exceptions
 
Similar Threads
synchronizing on an arbitrary Class object
Threading from seperate class
synchronized question
About synchoronized code blocks in java
Synchronized blocks