开发者

Why FileChannel in Java is not non-blocking?

I wanted to write a program which writes to multiple files simultaneously; thought it will be possible with one thread by using non-blocking mode. 开发者_Python百科But FileChannel does not support non-blocking mode. Does anybody know why?


UNIX does not support non-blocking I/O for files, see Non-blocking I/O with regular files. As Java should (at least try to) provide the same behaviour on all platforms, the FileChannel does not implement SelectableChannel.

However Java 7 will include a new AsynchronousFileChannel class that supports asynchronous file I/O, which is a different mechanism to non-blocking I/O.

In general only sockets and pipes truly support non-blocking I/O via select() mechanism.


Simply put, most operating systems doesn't treat regular files as something that can block - so they don't allow you explicitly set them to a non-blocking state.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜