On 1/24/2019 9:15 AM, Juha Nieminen wrote:
> Static objects, such as ones in namespaces (including nameless
> namespaces) and static class members, are constructed before
> main() is even called.
>
> I just want to make sure: Is it ok to use std::thread and the
> other multithreading standard utilities in the constructors of
> these objects?
Just be careful. I have seen nightmares where people create a thread in
the ctor, that calls a member of the object currently being constructed!
The damn thread calls the member _before_ the object is fully
constructed. This IS BADDDDD! I have had nightmares about fixing some
others code before.