Subj : Re: I write a multithread program with pthread, and meet a program To : comp.programming.threads From : Loic Domaigne Date : Mon Apr 11 2005 02:00 am Hello, > I want to use pthread_cancel() to stop a thread, but it can not do > correctly. > Here is a sample: [snip] > When the new thread is running to the point 1 and the main thread call > pthread_cancel() to stop it, the new pthread can not be stopped > correctly. Except the fact that you are not using correctly the condition variable (which should have a predicate associated to it), does commenting the following line help? pthread_mutex_unlock(&mutex); // cout<<"------------thread start"<