Subj : Re: thread destructor ala atexit() To : comp.programming.threads From : Chris Thomasson Date : Tue Aug 30 2005 03:46 pm "Frank Cusack" wrote in message news:m2d5nvgrsp.fsf@maguro.savecore.net... > Is there anything like pthread_atexit() which would register a destructor > to be run when a thread terminates? I have a module which plugs into an > existing framework. I want to create a thread local variable in my > module. > Initializing the variable allocates resources which must be destroyed upon > thread termination. > > But I don't control thread creation and destruction--that's handled within > the existing framework. > > I looked at cancellation but it doesn't seem like it will work. http://www.opengroup.org/onlinepubs/007908799/xsh/pthread_key_create.html That should do exactly what you want. .