• Post Reply Bookmark Topic Watch Topic
  • New Topic

exception in sync block  RSS feed

 
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.)
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!