• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Question about exception thrown from synchronized block of lock method

 
Jianhua Ren
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a synchronized block inside lock method like the following:
synchronized(lockedRecords){
validate(red); //may throw RecordNotFoundException
...
}
Question is that if RecordNotFoundExeption is thrown inside the above synchronized block, does the lock get released? I think it does, just want to confirm with your guys.
Thanks,
Jianhua
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 12007
215
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jianhua,
After the exception is thrown, the mutex lock for the lockedRecords object will become available again. Another thread will then be able to aquire that mutex.
Regards, Andrew
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic