Thread safety of cout

Dan Evison devison@pacificit.co.nz
Thu Oct 7 23:13:00 GMT 2004


> 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



More information about the Libstdc++ mailing list