Java multithreading reading a single large file

前端 未结 4 1273
长发绾君心
长发绾君心 2021-02-09 06:44

What is an efficient way for a Java multithreaded application where many threads have to read the exact same file (> 1GB in size) and expose it as an input stream? I\'ve notice

4条回答
  •  独厮守ぢ
    2021-02-09 07:11

    you can open the file multiple times in readonly mode. You can access the file in any way you want. Just leave the caching to the OS. When it's too slow you might consider some kind of chunk based caching where all threads can access the same cache.

提交回复
热议问题