3 ms·
People sometimes respond with some puzzlement to InterruptedException, unsure what they should do. All it means is that some other thread has requested that thi
by pron 5y ago
People sometimes respond with some puzzlement to InterruptedException, unsure what they should do. All it means is that some other thread has requested that this thread stop what it's doing. So do what you think your code should do in that situation. E.g. in the case of `say`, the most reasonable thing is to simply return.
You shouldn't normally call `Thread.currentThread().interrupt()` inside a `catch (InterruptedException e)` unless, perhaps, you don't throw anything. That would prevent any blocking operation inside cleanup code from working. As a general rule, a thread's interrupt status is set or InterruptedException (or some other exception) is thrown, but not both. That is how JDK methods also do it. If they throw — they clear the interrupt status.
- emccue 5y agoAight. I only started doing this recently after this advice here https://discord.com/channels/544924237773668373/930457954346491924/963003013667127338 https://discord.com/channels/544924237773668373/930457954346... I'll clear it from the examples
- K2L8M11N2 5y agoJust FYI, that link is not publicly accessible.
- deleted 5y ago[deleted]