• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

A question about throwing SecurityExeption in update method

 
Olena Golub
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Everyone!

I have a little bit doubts in my unlock method.
In this method I check if the record exists in the array, where I put the
locked record number and the locked cookie.


And my question is, do I need to call before throwing the Security Exception the lockedRecords.notifyAll()?
Or after throwing the exeption the current thread releases the lock at the lockedRecords object automatically?
Thanks a lot for you help!

Olena.
 
Uwe Schäfer
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Olena Golub:



And my question is, do I need to call before throwing the Security Exception the lockedRecords.notifyAll()?
Or after throwing the exeption the current thread releases the lock at the lockedRecords object automatically?


the lock is release as soon as the execution thread leaves the synchronized block/method, no matter how. so - to answer your question - No, you do not have to notify.

(i�m not sure what the notification would be good for, if there was no modification done to lockedRecords here)
 
Wei-ju Wu
Ranch Hand
Posts: 147
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Olena,

I do not see your passage where you invoke you wait(), but I guess you only do that in lock(). Assuming this, you do not need to call notifyAll() here, throwing the exception will get you out of the synchronized block and gives up the object lock (imagine you would put a return statement instead of the throw).
 
Olena Golub
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Uwe and Wei-ju,

Thanks a lot for your help!
I got it!
Regards,
Olena
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic