Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

3
  • Only problem is, a file could be enormous, a gigabyte long even. Wouldn't that consume a lot of memory to store it in memory and pass it to a single thread? Commented Jul 7, 2010 at 17:18
  • 1
    Read Jon's answer again. He's not suggesting that you store the entire file in memory all at once. Commented Jul 7, 2010 at 17:20
  • @icemanind: Stephen is right - I wasn't suggesting storing it in memory at all. Just use a single file handle, and a single thread using it to write. If you're worried that you'll be producing data faster than it can be written, you could always make the queue block so that there were never more than a certain number of entries waiting to be processed. (And my edit only added an extra bit of elaboration... it's not like it changed the approach.) Commented Jul 7, 2010 at 17:23