I will be afraid of conjecture ... one thing he can use is for parallel computing. Suppose you have two threads that perform very parallel computations, and you want the data to be written to one file. You can also pre-determine the size needed to store the output of each stream (say, 50 MB).
So, select a 100 MB file, start the stream starting recording at offset 0, and start stream # 2 with 50 MB. When the streams are completed, you will have one single file (otherwise, using separate files, you need to add the result from stream # 2 to stream # 1).
ASCII Art Attempt
============================== | 50MB | 50MB | [100 MB Total FileSize] | | | ============================== ^ ^ | | Thread 1 Thread 2
All that said, I never did that. It may not even work! You can simply share the file handle / stream between threads using some other synchronization mechanism, but then you will also have to reset the offset in each stream. Perhaps this or that is more effective.
On the one hand, there can be many disks if both streams are always written the same. Conversely, record synchronization can adversely affect the benefits of concurrency if there is a lot of controversy in record locking. And, as they often say, a profile and a test!
In any case, Iโm also interested in the โreal lifeโ scenario, which uses record sharing, and will monitor for additional answers!
source share