how to terminate a target thread

This is a discussion on how to terminate a target thread within the C++ Programming forums, part of the General Programming Boards category; HI ALL, my main program created one pthread.which is running infinite loop. when i want to terminate remote thraed i ...

  1. #1
    Registered User
    Join Date
    Mar 2004
    Posts
    19

    how to terminate a target thread

    HI ALL,
    my main program created one pthread.which is running infinite loop.
    when i want to terminate remote thraed i used pthread_cancel .
    But some time it may not cancelling the remote thread..
    how to terminate remote thread???Anyone please help me to find
    the solution...

  2. #2
    VA National Guard The Brain's Avatar
    Join Date
    May 2004
    Location
    Manassas, VA USA
    Posts
    903
    without seeing any code.. i would simply recommend setting a break; condition.. that will break out of the loop based on some criteria.
    • "Problem Solving C++, The Object of Programming" -Walter Savitch
    • "Data Structures and Other Objects using C++" -Walter Savitch
    • "Assembly Language for Intel-Based Computers" -Kip Irvine
    • "Programming Windows, 5th edition" -Charles Petzold
    • "Visual C++ MFC Programming by Example" -John E. Swanke
    • "Network Programming Windows" -Jones/Ohlund
    • "Sams Teach Yourself Game Programming in 24 Hours" -Michael Morrison
    • "Mathmatics for 3D Game Programming & Computer Graphics" -Eric Lengyel

  3. #3
    Registered User
    Join Date
    Dec 2004
    Posts
    95
    Unless the thread you wish to cancel has asynchronous cancellation enabled (via the appropriate flags in pthread_create or pthread_setcanceltype, the thread won't cancel until it reaches a cancellation point (assuming the cancel type is deferred - the default).

    A cancellation point is something like pthread_cond_wait, pthread_testcancel, and some other POSIX system functions..there's references with lists of cancellation points.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Shared memory implementation using thread
    By kumars in forum C Programming
    Replies: 5
    Last Post: 06-18-2008, 05:24 AM
  2. user thread library
    By Eran in forum C Programming
    Replies: 4
    Last Post: 06-17-2008, 02:44 AM
  3. multithreading in c
    By thebrighter in forum C Programming
    Replies: 8
    Last Post: 07-10-2007, 02:17 PM
  4. [code] Win32 Thread Object
    By Codeplug in forum Windows Programming
    Replies: 0
    Last Post: 06-03-2005, 04:55 PM
  5. Critical Sections, destroying
    By Hunter2 in forum Windows Programming
    Replies: 4
    Last Post: 09-02-2003, 11:36 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21