• Post Reply Bookmark Topic Watch Topic
  • New Topic

Threads and I/O

 
Michael Boehm
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am playing around with coding a simple file downloader. Is there any point in making this mult-threaded when the files has to be written to disk ? Can multiple threads write to disk at the same time ?
 
Paul Clapham
Sheriff
Posts: 21892
36
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you want a simple file downloader, then you will want to avoid multi-threading. Especially if you had in mind to have two threads working on separate parts of the same file.

Certainly multiple threads can write to disk at the same time. In fact I'm going to assume you meant to ask if they could write to a single file at the same time, because what you asked is obviously true. And yes, they could do that too. I'm just saying that once you start doing that, you can't call your code "simple" any more.
 
Michael Boehm
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the reply. Actually I only thought about writing to different files. It is surely due to my lack of CS knowledge, but why is this obvious ?
It wasn't clear to me if there was more than one "head" that could write to the hard disk at one time. So I even thought things might slow down using threads if using threads would increase the amount of movement of the "head". Feel free to laugh
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!