Subj : Re: Can C++ local static objects be made thread safe? To : comp.programming.threads From : David Schwartz Date : Wed Feb 09 2005 09:22 am "Marcin 'Qrczak' Kowalczyk" wrote in message news:87vf922dst.fsf@qrnik.zagroda... > If it caused a deadlock, the program would have to enter initialization > of a particular local static variable before the previous initialization > of that variable finished. But with the traditional non-thread-aware > implementation of local static initializers this has undefined behavior. > So it doesn't break anything which wasn't already broken. This analysis is not correct, it relies upon two different concepts of when initialization is finished. Remember, you need to wrap the entire initialization function in a lock of some sort, not just the process of determinine whether the initialization has taken place or not. It is perfectly legal for code inside the constructor to dispatch another thread and for that other thread to call functions which invoke static initializers. DS .