Subj : Re: Can C++ local static objects be made thread safe? To : comp.programming.threads From : David Schwartz Date : Thu Feb 03 2005 06:26 pm "Gianni Mariani" wrote in message news:2JudnbZqFeq2oZ_fRVn-2g@speakeasy.net... >> A threading standard >> must specifically restate any C++ standard guarantees that it provides in >> the context of threads. If we're talking POSIX, POSIX specifically >> requires accesses to shared data (which the static object is) to be >> protected by mutexes. > > Only if the shared data is modified. The thing is, it's not clear at what level the "modification" needs to take place. For example, consider a class that caches some information internally to save lookups. This can cause an access that is purely a "get information" operation to result in a modification to the internal state of the object. So, to be more precise, you must hold a mutex unless you can prove modification is impossible. In this case, you cannot. So a mutex is required. DS .