Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

exception in sync block

 
Rajani Deshpande
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If an exception is thrown inside a synchronized block will the lock on the object that was synchronized be automatically released?
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes. (Unless the exception is also caught inside the synhronized block.)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic