python 使用多线程同时执行多个函数
2021-03-03 10:28
标签:线程 reading thread pre name == time() 多线程 test python 使用多线程同时执行多个函数 标签:线程 reading thread pre name == time() 多线程 test 原文地址:https://www.cnblogs.com/xianhaiyan/p/14396912.htmlimport threading
import time
def test1():
print(1+5)
def test2():
print(5+8)
def test3():
print(5 + 8)
def test4():
print(5 + 8)
def test5():
print(5 + 8)
if __name__==‘__main__‘:
threads=[threading.Thread(target=test1),
threading.Thread(target=test2),
threading.Thread(target=test3),
threading.Thread(target=test4),
threading.Thread(target=test5)]
for i in threads:
i.start()
print(time.time())
运行结果:
6
1612968412.95072
13
1612968412.95072
13
1612968412.95072
13
1612968412.95072
13
1612968412.95072
上一篇:【SpringMVC】JSON使用(jackson、fastjson)
下一篇:pom.xml报错:Failed to read artifact descriptor for xxxxxx.jar问题的解决方法
文章标题:python 使用多线程同时执行多个函数
文章链接:http://soscw.com/index.php/essay/59474.html