Thread: End Thread assistance

  1. #1
    Registered User
    Join Date
    Mar 2008
    Location
    slovenia
    Posts
    25

    Smile End Thread assistance

    Hi, my question is in reference to ending threads from within a main function, (C extended function) _endthread is easy but can only be ran from within a runing thread, so if there are any known functions you might know, don't be shy to share:P, and there would be the possibility of using a global variable that the thread could check and terminate, but for the hell of knowing a function or two more, I had to ask.

    Thanks guys

  2. #2
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    always better to signal to the thread that it has to exit in some way, using global var, using pointer to the var passed as a parame or using SetEvent

    If all this is unavailable - you can forcibly terminateThread but this has several drawbaks like unrelease CriticalSection and not-freed memory...
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

  3. #3
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    On Windows, it will also leak the stack, so it's a very bad function.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Overwriting all in array, why?
    By guesst in forum C Programming
    Replies: 7
    Last Post: 10-09-2008, 05:56 PM
  2. [code] Win32 Thread Object
    By Codeplug in forum Windows Programming
    Replies: 0
    Last Post: 06-03-2005, 03:55 PM
  3. multithreading question
    By ichijoji in forum C++ Programming
    Replies: 7
    Last Post: 04-12-2005, 10:59 PM
  4. socket newbie, losing a few chars from server to client
    By registering in forum Linux Programming
    Replies: 2
    Last Post: 06-07-2003, 11:48 AM
  5. Replies: 12
    Last Post: 05-17-2003, 05:58 AM