我正在學習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