views:

116

answers:

1

I have a script that creates a thread which after 60 seconds (this thread) needs to kill the main thread. I`m not sure what command I can use to kill the main thread. I'm using Jython 2.5.1 and Thread.interrupt_main doesn't work.

Here is the code:

import threading
def exitFunct():
    #exit code here
t = threading.Timer(60.0, exitFunct)
t.start()
for i in range(1, 3000):
    print i
A: 

If the thread always terminates the main thread after 60 seconds, perhaps you'd be better using Thread.Join() in your main thread with a timeout?

And a link to the jython doc on threading

Although it has occurred to me that this would block your main thread..

It also looks like the answers here will help you.

If you post some example code that explains your problem and a deeper explanation of what you are trying to achieve with it, you'll get some better responses :)

Lee
Thanks, but yeah that can't happen, since the other thread is just timing the main one.
JeffGoetz
Thanks, will do!
JeffGoetz