开发者

How to kill main thread from sub thread in Jython

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开发者_JAVA百科 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


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 :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜