Re: To kill a GThread



On Friday 16 December 2005 02:13, Travis Miller wrote:
> Hi,
>
> I am trying to figure out how to kill a GThread that I created using
> g_thread_create().  I couldn't find anything in DevHelp that would
> indicate a way to kill a thread.  It seems the only way is to signal the
> thread and have the thread call g_thread_exit() itself.  Is there a way
> to kill a thread from another thread directly?

You would have to write some implementation-specific code.  If you know that 
the underlying implementation is pthreads, you could get the thread id of the 
thread you want to cancel and call pthread_cancel() on it, after calling 
pthread_cleanup_push() or pthread_cleanup_pop() as necessary to ensure the 
cancelled thread cleans up its resources (such as memory allocated on the 
heap).  I believe Windows has a similar call, but I do not know its name, nor 
whether it chooses a similar set of cancellation points.

Chris




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]