What is the optimal number of threads for performing IO operations in java?

前端 未结 7 1920
陌清茗
陌清茗 2021-01-01 17:54

In Goetz\'s \"Java Concurrency in Practice\", in a footnote on page 101, he writes \"For computational problems like this that do not I/O and access no shared data, Ncpu or

7条回答
  •  感情败类
    2021-01-01 18:10

    Like all performance related things it depends.

    If you're I/O bound, then adding threads won't help you at all. (Ok, as Steven Sudit points out, you might get an increase in performance, but it'll be small) If you're not I/O bound then adding threads may help

    Not trying to be smart, but the best way to find out is to profile it and see what works for your particular circumstances.

    Edit: Updated based on comments

提交回复
热议问题