Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Non-Blocking File Reads

Is there a non-blocking file read API in java? If not would it be wise to build one in C++ and call it from a java app via JNI?

like image 525
TheWolf Avatar asked Jan 19 '11 20:01

TheWolf


1 Answers

No, FileChannel does not extend SelectableChannel.

Probably because not all OSes support it.

Windows does, and in theory you could write a windows-specific C++ library and call it via JNI, but it is a lot of work to integrate this with java.nio.

I would rather have a worker thread copy the file contents to a pipe and do non-blocking reads on the other end of the pipe.

like image 126
finnw Avatar answered Oct 25 '22 06:10

finnw