This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: Thread safety of cout
> The general rule is simple: if two threads manipulate the same,
> visible object, they must control access by themselves. The
> only things the library locks itself are invisibly-shared objects,
> such as a free-memory pool, or a string representation shared
> between two visible string objects.
>
> I would expect any program that uses cout in more than one thread,
> without locking, to fail in random ways. A deadlock or crash means
> you got lucky, because by the specs in that case it's allowed to
> erase your disk and impregnate your sister.
ok, thanks. My mistake. For some reason I thought cout and cerr were
specially locked.
Dan