• Post Reply Bookmark Topic Watch Topic
  • New Topic

Synchronized and exceptions

 
Chris Bicnal
Ranch Hand
Posts: 99
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: 99
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
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!