Mailing List Archive

Support open source code!


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

Re: tlug: multithread (fwd)



On Thu, 23 Mar 2000, Uva Coder wrote:

> ---------- Forwarded message ----------
> Date: Thu, 23 Mar 2000 16:10:46 +0300
> From: PKaewprasert@example.com
> To: owner-tlug@example.com
> Subject: multithread
> 
> > Hello, 
> > 
> > I just subscribed to the tlug and tlug-post mailing list 
> > after doing research on the internet regarding multithread
> > programming. In the tlug mail archive, I found the answer 
> > from Scott Stone to Mike Fabian's question titled
> > "Multithreading, how to learn" and I have further question 
> > regarding your following message:
> > 
> > "Have your main program call pthread_cancel(thread) if you 
> > want to stop the child thread, or have the child call 
> > pthread_exit if it'll terminate itself.
> > Otherwise the thread terminates when childThreadProcess 
> > returns."
> > 
> > I would like to know if I should use pthread_exit at the 
> > end of the function that will be run in the new thread or 
> > the thread will automatically terminate itself at the end 
> > of the function without pthread_exit. And how do we check 
> > that thread exists or not after childThreadProcess returns?.
> > 
> > I have sent e-mail to Scott directly but unfortunately the 
> > e-mail was bounced back. So if anyone know, or Scott is 
> > reading this email, please help. Any suggestion will be 
> > really appreciated.

once the childThreadProcess returns, the thread is dead.  only use
pthread_exit if you need to explicitly terminate the thread before the end
of the function's execution (ie, on error or what have you).

I think that you can just check to see if the thread handle is NULL or not
to see if it still exists.  It's been a while, so check the man page for
the pthreads functions.  Find them in man section 3.

--------------------------
Scott M. Stone, CCNA <sstone@example.com>
UNIX Systems and Network Engineer
Taos - The SysAdmin Company 

--------------------------------------------------------------------
Next Nomikai Meeting: April 20 (Thu) Linux Conference 2000 Spring Ed.
Next Technical Meeting: May 13 (Sat) 13:30 Temple University Japan
* Topic: TBD
--------------------------------------------------------------------
more info: http://www.tlug.gr.jp        Sponsor: Global Online Japan


Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links