in reply to threads::question: where is the threads->cancel() call?

I don't know about how pthreads.h fits into this, but if you want to cancel the execution of a thread, 1 way is to use a shared variable, and when the thread sees that shared variable set to it's cancel value, then "return" in the thread ( and join if not a detached thread).

Maybe the pthread_cancel is used to abruptly terminate a thread, like when an 'exit' or 'exec' is called from some other sibling thread.


I'm not really a human, but I play one on earth. flash japh
  • Comment on Re: threads::question: where is the threads->cancel() call?

Replies are listed 'Best First'.
Re^2: threads::question: where is the threads->cancel() call?
by turo (Friar) on Feb 15, 2006 at 15:02 UTC

    yes, pthread_cancel, is like 'use the force' with any thread you've launched ... :-) ...


    The scheme of changing a shared variable, doesn't help all the times ...

    perl -Te 'print map { chr((ord)-((10,20,2,7)[$i++])) } split //,"turo"'