[Tutor] Killing threads

Tobin, Mark Mark.Tobin@attcanada.com
Wed, 20 Jun 2001 13:57:01 -0600


Ok, I admit it, I can't figure this threading problem out.  I have two
threads called in the main() function:

#Code to follow

def main():
    a = Account()
    a.arp = [300]
    a.threads = []
    t = threading.Thread(target = a.checker, args = (a.arp))
    a.threads.append(t)
    u = threading.Thread(target = a.menu, args = ())
    a.threads.append(u)
    a.nthreads = range(len(a.threads))
    for i in a.nthreads:
        a.threads[i].start()
    for i in a.nthreads:
        a.threads[i].join()

One of the threads, u, is active and provides a (so far) basic interface for
the user through the menu method of the class account.  The second, t, is
generally dormant, but pops up once in a while to check a single flag, then
falls back to sleep.  I need for the active, u, thread to be able to kill
both threads by calling another function quitter().

I know this shouldn't be hard, but I have no idea how to accomplish this.
When I look in the documentation at threading.Thread I can't find any
obvious method to kill the threads.  Can somebody help me, or am I doing
this entirely wrong?  This whole threading concept is really new to me and
I'm just starting to get my head around the idea...

Thanks, 
Mark