Python 线程最小示例
此最小示例展示如何创建每秒打印 Hello world 的线程:
thread_example.py
import threading
import time
def my_thread_func():
while True:
print("Hello world")
time.sleep(1)
my_thread = threading.Thread(target=my_thread_func)
my_thread.start()Check out similar posts by category:
Python
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow