[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
Re: A thread object -- GtkThread
- From: Gustavo Joćo Alves Marques Carneiro <ee96090 fe up pt>
- To: gtk-app-devel-list redhat com
- Subject: Re: A thread object -- GtkThread
- Date: Fri, 18 Feb 2000 15:27:16 +0000 (WET)
On Thu, 17 Feb 2000, Steven Hanley wrote:
> Gustavo Joćo Alves Marques Carneiro wrote:
>
> > The question is: is there a better way to do this? Specifically, I
> > don't know of any function from the pthread library to check if a thread
> > has terminated -- I'm using a flag and the timeout function. I don't like
> > this very much, but it's the best I could do.
>
> yes there is a way to see if a thread has terminated, the pthread_join
> function, it works like waitpid in normal unix programming.
>
> however as there is no parent/child relationship in the threads as such
> it allows any thread to wait on any other thread. more than one thread
> calling pthread_join is undefined.
>
> it is int pthread_join (pthread_t tid, void **status);
>
> status can be null, tid is the thread you want to wait on (this is a
> blocking call)
That is the problem with pthread_join: it is a blocking call. I think
you misunderstood me. I don't want to find out if the thread has
terminated *abnormally*, I want to find out if it has finished (normally
or not) without waiting for it, just like waitpid allows one to do, with
the WNOHANG option.
>
> if status is not null, *status will contain the return value, you can
> check this against PTHREAD_CANCELLED to see if it was stopped
> abnormally, otherwise *status of course contains the return value of the
> thread function.
>
> See You
> Steve
>
>
--
Gustavo J.A.M. Carneiro
[reinolinux.fe.up.pt/~ee96090]
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]