# 线程类
from threading import Thread
def func():
for i in range(1000):
print("func", 1)
if __name__ == '__main__':
t = Thread(target=func) # 创建线程并给线程安排任务
t.start() # 多线程状态为可以开始工作状态,具体的执行时间由CPU决定
for i in range(1000):
print("main", i)
# class MyThread(Thread): #(Thread)继承了thread
# def run(self): # 固定的 -> 当线程被执行的时候,被执行的就是run()
# for i in range(1000):
# print("子线程", i)
#
# if __name__ == '__main__':
# t = MyThread()
# t.start() # 开启线程
#
# for i in range(1000):
# print("主线程", i)
标签:__,Thread,range,线程,print,多线程,1000
From: https://www.cnblogs.com/Wesuiliye/p/17176912.html