def printHello(): while True: print("This is the hello threading...") time.sleep(1) def printNihao(): while True: print("This is the Nihao threading...") time.sleep(2) if __name__ == '__main__': t1 = threading.Thread(target=printHello) t2 = threading.Thread(target=printNihao) t1.setDaemon(False) t2.setDaemon(False) t1.start() t2.start() print("main threading ended...")
创建threading.Thread对象
最新推荐文章于 2024-07-14 14:59:27 发布