为什么我们从Java 1.6中的FileChannel.map获取ClosedByInterruptException?

时间:2009-07-21 19:36:48

标签: java nio jdk1.6

我们的一位客户抱怨说,偶尔我们对FileChannel.map的来电失败了ClosedByInterruptExceptionJavadoc并未将此列为合法可能性。有谁知道这里会发生什么?

Cause0: java.nio.channels.ClosedByInterruptException
Cause0-StackTrace:
at java.nio.channels.spi.AbstractInterruptibleChannel.end(AbstractInterruptibleChannel.java:184)
at sun.nio.ch.FileChannelImpl.map(FileChannelImpl.java:772)

2 个答案:

答案 0 :(得分:23)

通道操作绑定到执行操作的线程。如果此线程中断,则由于IO安全问题而关闭流/通道。

答案 1 :(得分:7)

最后一条评论包含答案。正在使用一个线程池,并且在关闭中断时已经交付。