【发布时间】:2013-01-15 13:51:26
【问题描述】:
我知道在引入 InterruptedIOException 时没有太多选择;它必须是 IOException 的子类。
InterruptedIOException 的唯一存在无疑会让你想知道一个线程是否被中断了。那是因为如果你想维护线程被中断的信息,你必须区别对待 InterruptedIOException 和 IOException。
虽然 InterruptedIOException 是为 java.nio 发明的,但据报道,至少在 Solaris 下,有 java.io 方法会抛出InterruptedIOException。此外,对于新的 Android 版本,库可能会从 java.io 迁移到 java.nio 或以某种方式映射其他方法。
我倾向于认为应该考虑 InterruptedIOException 以确保安全。你怎么看?见解、经验、策略?
【问题讨论】:
标签: java android exception-handling interrupted-exception