aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes A question about throwing SecurityExeption in update method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "A question about throwing SecurityExeption in update method" Watch "A question about throwing SecurityExeption in update method" New topic
Author

A question about throwing SecurityExeption in update method

Olena Golub
Ranch Hand

Joined: Jan 17, 2005
Posts: 113
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.


SCJP 1.4<br />SCJD 1.4 (in progress)
Uwe Schäfer
Ranch Hand

Joined: Mar 15, 2005
Posts: 52
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)


scja|scjp|scjd|scwcd|scbcd|scdjws|scmad
Wei-ju Wu
Ranch Hand

Joined: Feb 16, 2005
Posts: 147
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).


"The UrlyBird catches the certificate. And he's gonna FlyByNight"<br /> <br />SCJP 1.2/5.0, SCJD, SCBCD, SCWCD, SCEA
Olena Golub
Ranch Hand

Joined: Jan 17, 2005
Posts: 113
Hi Uwe and Wei-ju,

Thanks a lot for your help!
I got it!
Regards,
Olena
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: A question about throwing SecurityExeption in update method