tags:

views:

58

answers:

2

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. But FileChannel does not support non-blocking mode. Does anybody know why?

+1  A: 

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.

nos
+2  A: 

Java 7 will include a new AsynchronousFileChannel class that supports non-blocking file I/O, albeit by a different mechanism to selectors.

In the meantime, you could use multiple threads to achieve the same effect.

Stephen C