File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

[URLyBird] InterruptedException

 
Mihai Radulescu
Ranch Hand
Posts: 918
IntelliJ IDE Java Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
B Chen
Ranch Hand
Posts: 89
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Mihai Radulescu
Ranch Hand
Posts: 918
IntelliJ IDE Java Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic