Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Synchronized and exceptions

 
Chris Bicnal
Ranch Hand
Posts: 96
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 489
2
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The object will be released no matter how it happend...ie by throw exception or by end of execution synchronized block.
 
Chris Bicnal
Ranch Hand
Posts: 96
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Good stuff, that's what I thought although I wanted to make sure!

Thanks!

Chris
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic