How do I know when a thread quits?

harold fellermann harold.fellermann at upf.edu
Tue Jun 7 15:45:38 CEST 2005


Hi,

> I want a reliable way of knowing when the child
> thread finished execution so that I can make the main thread wait till
> then.
>
> Any ideas?

use a lock. the subthread allocates the lock and releases it after 
processing.
the main thread must wait until the lock is released. otherwiese, use 
the
higher level Threading module which provides a function Thread.join 
that allows
the main thread to wait for the subthread. I think it uses the same 
mechanism
that I explained above.

- harold -

--
Outside of a dog, a book is a man's best friend: and inside a
dog, it's too dark to read.
-- Groucho Marx




More information about the Python-list mailing list