Subj : Can C++ local static objects be made thread safe? To : comp.programming.threads From : roland Date : Mon Jan 17 2005 05:35 pm I stumbled about the following problem: struct A { A() { } ~A() { } }; void foo() { static A aA; } The ctor of aA might be called "the first time control passes through its declaration". (C++ Standard 6.7) This is fine in a single threaded application. But hows about multithreaded? There obviously does exist a race condition for the flag that possibly prevents second invocation of the ctor. Since this is compiler depandant, is there a way to safely use local static objects, or should they simply banned from MT applications? Any ideas? Roland .