Subj : Re: Optimization to Jeffrey Richter's COptex (Windows)? To : comp.programming.threads From : Alexander Terekhov Date : Wed Jan 26 2005 07:06 pm Joseph Seigh wrote: [... ordinal reads ...] > No. If a thread releases the lock, it sets the owning thread id to zero. > it can only see zero or the thread id of another thread. Absent application synchronization with respect to termination and creation of threads, it may (in theory; formally speaking based on the lack of constraint imposed on the threading impl) see id of another already terminated thread that happens to have the same value. t0: thread 666 unlocks the mutex and terminates; t1: thread 000 (it can still see 666) creates another thread and it gets reclaimed id 666. It "inherits" the same view of memory as thread 000 (sees 666); t3: thread 001 locks the mutex. t4: new thread 666 attempts to lock the mutex and thinks that it already owns it... not good, oder? regards, alexander. .