📜  python同时循环两个while循环 - Python代码示例

📅  最后修改于: 2022-03-11 14:47:02.601000             🧑  作者: Mango

代码示例1
import threading
import time

def infiniteloop1():
    while True:
        print('Loop 1')
        time.sleep(1)

def infiniteloop2():
    while True:
        print('Loop 2')
        time.sleep(1)

thread1 = threading.Thread(target=infiniteloop1)
thread1.start()

thread2 = threading.Thread(target=infiniteloop2)
thread2.start()