python 使用装饰器开启多线程
资料:
https://blog.csdn.net/weixin_40481076/article/details/101594705/ python多线程详解(超详细)
https://blog.csdn.net/weixin_44244190/article/details/124478884 【python3】python实现多线程(简单操作)
Python使用装饰器开多线程
??这个方法我自己用的很多比较好用,可以将多线程的调用使用的很优雅整洁
https://zhuanlan.zhihu.com/p/208260624 python终止线程(直接return方便快捷doge)
import time
import threading
def threadDecorator(func):
def wrapper(*args, **kwargs):
thread = threading.Thread(target=func, args=args, kwargs=kwargs)
thread.start()
return thread
return wrapper
@threadDecorator
def demoFunc():
for i in range(6):
print(i)
time.sleep(1)
@threadDecorator
def demoFunc02():
for i in range(6):
print(time.time())
time.sleep(1)
if __name__ == '__main__':
demoFunc()
demoFunc02()