If I had code which were to read every word of a file into an ArrayList or HashSet, would it be any faster to split the code into multiple worker threads and assign each a chunk of the file to work on (assuming multiple cores)? My gut says no since the I/O would usually be the bottleneck rather than the CPU in a case like this.
If I had code which were to read every word of a file into
Share
It depends. Your line of thinking that the IO is going to be the bottleneck could be correct since a lot of disks work in a serial fashion. But, what if that disk were special like an SSD or a RAID that really did support concurrent access? Also, if there were a significant amount of CPU bound post processing that needs to be done with the data then you could get that going concurrently while another batch of data is being read. Do not write off the concurrent options so quickly!