jQuery in Action, 3rd edition
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes [URLyBird] InterruptedException 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 "[URLyBird] InterruptedException" Watch "[URLyBird] InterruptedException" New topic

[URLyBird] InterruptedException

Mihai Radulescu
Ranch Hand

Joined: Sep 18, 2003
Posts: 918

I refactoring my URLyBird - the lock manager and I have a dilemma.
In my lock method I use a spin look - something like :

My dilemma is about the InterruptedException, or better about its treatment. Here I only log it, is this correct ?
I don't think that can be useful to inform the user(with an other exception let's say).

Regards, Mihai
[ April 10, 2006: Message edited by: Mihai Radulescu ]

B Chen
Ranch Hand

Joined: Dec 27, 2005
Posts: 89
If your program is designed so that the only reason for InterruptedException is spurious wakeup, I would do nothing (leave the catch block empty) and continue the loop.

SCJD<br />SCJP 1.4
Mihai Radulescu
Ranch Hand

Joined: Sep 18, 2003
Posts: 918

Hi Chen

Tahnks for your answer.
The only reason why I catch the InterruptedExceptoin is to be shore that a "accidental" wakeup will not change (drastic) the workflow - the locked thread leave the while loop even if the varaible condition(the records.containsKey(recId)) is not accomplish, this can lead easly to a dead look.
By example if some client(front end) is implemented and in this client the someone just try to call the interrupt() metohd in a try/catch block then the the lock manager can be skiped -> records can be altered without locking.

Regards, Mihai
I agree. Here's the link: http://aspose.com/file-tools
subject: [URLyBird] InterruptedException
It's not a secret anymore!