Reading a single file with Multiple Thread: should speed up?

后端 未结 3 436
孤独总比滥情好
孤独总比滥情好 2020-12-06 18:57

I\'m reading a file which conatins 500000 rows. I\'m testing to see how multiple thread speed up the process....

private void multiThreadRead(int num){

             


        
3条回答
  •  长情又很酷
    2020-12-06 19:44

    The reason you are seeing a slow down when reading in parallel is because the magnetic hard disk head needs to seek the next read position (taking about 5ms) for each thread. Thus, reading with multiple threads effectively bounces the disk between seeks, slowing it down. The only recommended way to read a file from a single disk is to read sequentially with one thread.

提交回复
热议问题