How to read a file using multiple threads in Java when a high throughput(3GB/s) file system is available

前端 未结 2 1542
情深已故
情深已故 2020-12-06 15:09

I understand that for a normal Spindle Drive system, reading files using multiple threads is inefficient.

This is a different case, I have a high-throughput

2条回答
  •  难免孤独
    2020-12-06 15:53

    You should first try the java 7 Files.readAllLines:

    List lines = Files.readAllLines(Paths.get(path), encoding);
    

    Using a multi threaded approach is probably not a good option as it will force the filesystem to perform random reads (which is never a good thing on a file system)

提交回复
热议问题