多线程基本案例
import threading
import time
def hello():
while True:
print("=== hello ... ...")
time.sleep(0.2)#等待0.2秒
def world():
while True:
print("=== === world ... ...")
time.sleep(0.3)#等待0.3秒
if __name__ == '__main__':
# 创建线程对象
hello_thread = threading.Thread(target=hello)
world_thread = threading.Thread(target=world)
# 启动线程
hello_thread.start()
world_thread.start()
#手动停止,否则一直不停