Reputation: 900
In Windows, can I open multiple InputStreams to the same file from a single application? I'm programming in Linux right now and I'd like to know before I screw up an entire process....
Basically I'm parsing a zip file. I'd like to thread the task of unzipping, reading, writing and md5sum out to 2 separate cores so I can continue the process and move on to the next one which will do the same.
I can do this on Linux but I'm worried about Windows because they lock files.
Upvotes: 1
Views: 402
Reputation: 24021
You don't need to worry about this - unless you go and create the file lock, the file will not be locked from multiple concurrent reads. However, if you're reading and writing concurrently you will need to be careful with your buffering.
Regardless, I suspect that you'll be disk bound here and won't get anything by multithreading this, but I don't know the particulars of your situation.
Upvotes: 2
Reputation: 53674
windows does not lock multiple readers. that will work fine.
that said, it's hard to imagine that the cpu is the bottleneck in this scenario. do you actually get measurably better performance multi-threading the unzip? seems like io would be the more likely bottleneck (in which case multi-threading often doesn't help).
Upvotes: 2