MultiThreading I/0 under linux.

Hello,
Can I write many files from many threads simultaneously?( one file - one thread ) using std::ofstream. Is using many instances of ofstreams( for differnet files) thread-safe. Where can I read about it for linux. ( for example for Windows I found this article http://msdn.microsoft.com/en-us/library/c9ceah3b(v=vs.100).aspx ). I use Ubunutu 12/04 LTS.
Thanks in advance
Can I write many files from many threads simultaneously?( one file - one thread ) using std::ofstream.
Yes.

Is using many instances of ofstreams( for differnet files) thread-safe.
Yes.

The link isn't covering your case. It's talking about multiple threads writing to a single stream without synchronisation.

The link isn't covering your case. It's talking about multiple threads writing to a single stream without synchronisation.


It is safe to read and write to one instance of a type even if another thread is reading or writing to a different instance of the same type.
It is safe to read and write to one instance of a type even if another thread is reading or writing to a different instance of the same type.
No.

You can use STL containers/streams safely within a thread, and use them in parallel in different threads as long as they stay in their respective threads.

Once you start going across threads of execution, you need to synchronise accss. This is no different from what you'd need to do for your own objects.
Topic archived. No new replies allowed.