并发编程 启动与停止线程 # Code to execute in an independent thread import time def countdown(n): while n > 0: print('T-minus', n) n -= 1 time.sleep(5) # Create and launch a thread from threading import Thread t = Thread(target=countdown, args=(10,)) t.start() if t.is_alive(): print('Still running') else: print('Completed') t.join() t.daemon=True 如果线程执行一些像I/O这样