Reputation: 43
I'm reading text form a huge file, line by line, perform some operations on them and then store results in different files. If I will have two thread, one that read the data from one file, will other thread be able simultaneously write data to another file? Or as they are o the same hard disk multithreading won't make sense as they will wait for each other?
Upvotes: 0
Views: 463
Reputation: 17415
If I understand right, you have the three steps
Of course, the hard disk can't perform a read and write operation at the exact same time. However, it could support this:
In short, while processing, your program is CPU-bound and the HD is idle. While writing, it is HD-bound (or IO-bound) and the CPU is idle. Interleaving these things can improve overall throughput.
Upvotes: 2