I have huge file (about 500k fixed size records or more). I wanted to know if I can read it in parallel via different threads.
I have not used Java NIO packages yet! (sounds strange, but it is true). Is there a way we can read the file in parallel using any of the NIO concepts? I am still going through tutorial and may be some experiments but I thought of asking here.
Also, if you know of any other/better way of reading a file in parallel other than NIO, it would be great if you share it here.
Only if the chunks of the file are on different drives. The OS is going to be the limiting factor on your being able to read different parts of the same file in parallel. In fact trying to do that may slow down the process because the read head on the drive could have to jump back and forth slowing down the process. If you could do the reads at a lower level (ie in machine language) and you knew the relative speed of the disk spinning vs the read time to read a sector from the disk (assuming the disk is sectored), then you could time your reads to start a read a selected sector just before the read head gets to that sector. That might make it possible to read a full track in two rotations (reading sectors 0, 2, 4 and then 1, 3 5) versus reading one sector per rotation. 6 sectors = 6 rotations vs 2.