Subj : Re: Can C++ local static objects be made thread safe? To : comp.programming.threads From : David Schwartz Date : Fri Feb 11 2005 11:03 am "Bruce Visscher" wrote in message news:1108147434.393700.84730@o13g2000cwo.googlegroups.com... > Sorry to catch the tail end of this but if a compiler doesn't support > "__thread" would volatile suffice in some/most/any cases? Usually "__thread" makes a variable thread-local. Whereas 'volatile' is used when a variable might be modified from a signal handler. So I'm not sure how one could ever do the job of the other. > This issue happens to have caught my attention recently. I think I > just observed a situation where essentially this code fails on VMS > under CXX but without either __thread or volatile. > > Sadly, I believe CXX has for a long time implemented something like > what I've read in this thread that GCC 4.0 does. I never took > advantage of this because I was afraid it wouldn't be portable. If you're trying to access a variable in a thread-safe way under UNIX, it's usually thread pthread_mutex functions that you want. DS .