我正在学习Python中的多线程,并使用以下链接中的代码。Python中的多线程(pythonwin挂起)
http://www.tutorialspoint.com/python/python_multithreading.htm
的PythonWin的IDE挂起(无响应)超过30分钟,请帮我,如果有在代码中的一些问题。
import thread
import time
# Define a function for the thread
def print_time(threadName, delay):
count = 0
while count < 5:
time.sleep(delay)
count += 1
print "%s: %s" % (threadName, time.ctime(time.time()))
# Create two threads as follows
try:
thread.start_new_thread(print_time, ("Thread-1", 2,))
thread.start_new_thread(print_time, ("Thread-2", 4,))
except:
print "Error: unable to start thread"
while 1:
pass
谢谢,它删除了最后一个代码后 – user2439245