python实现多线程
2021-06-04 00:04
标签:main __name__ from thread import star targe threading 函数 python实现多线程 标签:main __name__ from thread import star targe threading 函数 原文地址:https://www.cnblogs.com/gmbjzg/p/14667229.htmlfrom 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()
下一篇:js实现冒泡排序算法