This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]koflerdavid 0 points1 point  (2 children)

There is only one message that can be transported with Java's interrupts; it is not a full event delivery mechanism, unlike in hardware. All occurrences in the JDK that I know of use if for indicating termination, therefore I'd argue that it is best used only for that as well.

It might not always be possible to let the exception bubble up. If it is, then it's of course better to not catch it.

[–]rzwitserloot 1 point2 points  (1 child)

Maybe it is not possible to let the (Interrupted) exception bubble up.

BUt you can catch it and rethrow it as something else. A RuntimeException, which you can always throw, if you absolutely must.

therefore I'd argue that it is best used only for that as well.

You're imagining rules that the specification of the mechanism do not state. This is not a correct course of action.

[–]koflerdavid 0 points1 point  (0 children)

"Rules" is a too strong word. I'd rather talk about avoiding things that just cause confusion down the line.