Subj : Re: Can C++ local static objects be made thread safe? To : comp.programming.threads From : David Schwartz Date : Fri Feb 11 2005 04:51 pm "Bruce Visscher" wrote in message news:1108159321.832036.245890@z14g2000cwz.googlegroups.com... >> It *might*. But don't you want to write code that guaranteed to >> work because it complies with the relevant standards > > Absolutely. > >> rather than code that just >> happens to work because you fixed all the problems that were biting >> you but left the ones that didn't happen to bite you that day, on >> that compiler, on that platfor, with that data set? > > No, I want to avoid that. > Before "resorting" to pthread_key_create / pthread_getspecific / > pthread_setspecific / pthread_key_delete I could also maybe try to use > atomic exchange for those platforms that have that. But this is > starting to look a little cumbersome. > >> and your code will not be portable. > > That's what I am trying to avoid. Why not use the pthread_once stuff? Or a statically initialized mutex? DS .