-
June 22nd, 2011, 07:42 AM
#1
Stop a pthread
I need to know what is the simplest way to stop a pthread. I dont want to use nor I am using mutex lock and unlock, but my threads are running fine and I want to stop the running thread if a global variable is set.
can somebody throw some light on this.
Thanks
-
June 22nd, 2011, 08:10 AM
#2
Re: Stop a pthread
Use pthread_cancel function:
http://www.kernel.org/doc/man-pages/..._cancel.3.html
When pthread_cancel is called from another thread, and one of cancellation points is executed, thread is terminated. Full list of cancellation points:
http://www.kernel.org/doc/man-pages/...threads.7.html
If thread doesn't contain cancellation points (like computation thread), use pthread_testcancel on every iteration.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|