50c Subj : Re: Can C++ local static objects be made thread safe? To : comp.programming.threads From : Giancarlo Niccolai Date : Sun Feb 06 2005 02:44 am Marcin 'Qrczak' Kowalczyk wrote: > Giancarlo Niccolai writes: > >> But if I add a mutex for static initializers at Consumer c and at >> Producer p points, the constructor of the consumer will still not be >> exited when it will wait for p to receive the initialization data, >> blocking on MAX_SIZE. But P can't go, as it is locked waiting for >> the construction of C to release the static initializer mutex. > > No, P doesn't wait for the construction of C. Each function has a > separate static initializer mutex. > Aaarrrggg. That's even worse. I don't want to have thousand of mutexes I can't control around, especially when I don't need them. And I can write code that would be broken also by a-mutex-per-class thing. And... btw... have you thought about how to... INITIALIZE EACH MUTEX IN A THREAD-SAFE WAY? One can be done a the beginning of the program... but a possibly endless number of them? Sorry, the whole idea: 1) solves an unexisting problem 2) can break correct programs 3) makes an ugly thing (static initialization) just worse. Bests, Gian. . 0