import thread
from time import sleep, ctime
def text():
print 'Hello thread'
def main():
thread.start_new_thread(text, ())
if __name__ == '__main__':
main()
以上程序在win7下执行时,会报出错误,错误信息:
This application has requested the Runtime to terminate it in an unusual way.
后台发现在开启线程后面加上一句话:
time.sleep(1)
后来在命令行下执行这个程序,发现没加time.sleep(1)时,程序报错:
Unhandle exception in thread started by
Error in sys.excepthook:
Original exception was:
加上time.sleep(1)则正常执行。