CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: Stop a pthread

  1. #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

  2. #2
    Join Date
    Jul 2002
    Posts
    2,543

    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
  •  





Click Here to Expand Forum to Full Width

Featured