This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
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


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "[URLyBird] InterruptedException" Watch "[URLyBird] InterruptedException" New topic
Author

[URLyBird] InterruptedException

Mihai Radulescu
Ranch Hand

Joined: Sep 18, 2003
Posts: 916

Hi,
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 ]

SCJP, SCJD, SCWCD, OCPJBCD
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: 916

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
 
Similar Threads
URLyBird question
pls validate my locking strategy - all inputs are g8ly appreciated. (URLyBird)
URLyBird Locking
Can we modify the interface? (URLyBird)
URLybird