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

Posted by marc on Stack Overflow See other posts from Stack Overflow or by marc
Published on 2009-08-06T16:08:35Z Indexed on 2012/11/24 23:04 UTC
Read the original article Hit count: 186

Filed under:
|
|

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 Ncpu+1 threads yield optimal throughput; more threads do not help, and may in fact degrade performance..."

My question is, when performing I/O operations such as file writing, file reading, file deleting, etc, are there guidelines for the number of threads to use to achieve maximum performance? I understand this will be just a guide number, since disk speeds and a host of other factors play into this.

Still, I'm wondering: can 20 threads write 1000 separate files to disk faster than 4 threads can on a 4-cpu machine?

© Stack Overflow or respective owner

Related posts about java

Related posts about multithreading