Using threadpools/threading for reading large txt files?

后端 未结 3 611
遇见更好的自我
遇见更好的自我 2021-01-21 04:29

On a previous question of mine I posted:

I have to read several very large txt files and have to either use multiple threads or a single thread to do so depending on

3条回答
  •  借酒劲吻你
    2021-01-21 04:59

    So, the newFixedThreadPool() call will return an instance of ExecutorService. You can reference the JavaDoc, which is pretty comprehensive and contains a workable example. You will want to either submit or invokeAll a number of Callables implementing your file-processing tasks, giving you a number of Futures in return. Their get() methods will give you the result of the task execution upon completion (you have to write that part yourself :))

提交回复
热议问题