12345678910111213from threading import Threaddef func(): for i in range(1000): print('func', i)if __name__ == '__main__': t = Thread(target=func) # 创建线程并给线程安排任务 t.start() # 多线程状态为可以开始工作状态,具体执行时间由CPU决定 for i in range(1000): print('main', i) 运行结果: 1234567891011121314151617181920212223funcmain 0 0funcmain 1func 2func 3func 4 1main func 5func 6func2 7......funcmain 998992funcmain 999993main 994main 995main 996main 997main 998main 999