标签:main __name__ from thread import star targe threading 函数
from threading import Thread
# 方式一
# def sub_thread():
# for i in range(11):
# print(i)
# def main():
# t = Thread(target=sub_thread)
# t.start()
# for i in range(11):
# print(i)
# 方式二
class SubThread(Thread):
def run(self):
"""
子线程任务函数
"""
for i in range(11):
print(i)
def main():
t = SubThread()
t.start()
for i in range(11):
print(i)
if __name__ == "__main__":
main()
标签:main __name__ from thread import star targe threading 函数
原文地址:https://www.cnblogs.com/gmbjzg/p/14667229.html