self_example/TensorFlow_eaxmple/threading_try/join类.py

16 lines
368 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import threading, time
def doWaiting():
print('start waiting:', time.strftime('%S'))
time.sleep(3)
print('stop waiting:', time.strftime('%S'))
thread1 = threading.Thread(target=doWaiting)
thread1.start()
time.sleep(1) # 确保线程thread已经启动
print('start join')
thread1.join() # 将一直堵塞直到thread1运行结束
print('end join')