Subj : Re: Can C++ local static objects be made thread safe? To : comp.programming.threads From : Gianni Mariani Date : Sun Feb 06 2005 11:05 pm Giancarlo Niccolai wrote: > Gianni Mariani wrote: > > >>Giancarlo Niccolai wrote: >>... >> >>>Having a reentrant mutex cheching for each initializer initialization 1) >>>does not fix the generic problem of initialization during static init >>>with MT already going and 2) would be ... crappy. >> >>Why ? Honestly, why would this not solve the problem generically ? > > > Because MUTEXING is not the heart of multithreading!!! You can mutex each > and every single access to any variable, even from the stack, in all your > program and still have thread unsafe code!!! > > Mutexing the things up won't make your code SAFE. It may make it a little > bit safer in some cases, but mutexing, although sometimes necessary, is > rarely enough except in academic cases. > Stick to facts. My proposal solves the problem of static locals being initialized in a generic way - period -. PLEASE PLEASE, stick to the theme. If you wish to do somthing else, go ahead, however there are definite merits to my original proposal. a) Generic solution - threads and static locals are safe b) Can be made fast (using thread specific variables if the compiler supports it) c) No maintenance needed - works every time. Sounds like a Good (TM) thing to me. Tell me what I am missing (facts only please, no religion). .