import gevent
from gevent
import monkey
import time
monkey
.patch_all
()
def get_body(i
):
print("start", i
)
time
.sleep
(2)
print("end", i
)
tasks
= [gevent
.spawn
(get_body
, i
) for i
in range(3)]
gevent
.joinall
(tasks
)
import threading
import time
def get_body(i
):
print("start", i
)
time
.sleep
(2)
print("end", i
)
for i
in range(3):
t
= threading
.Thread
(target
=get_body
, args
=(i
,))
t
.start
()
效果
转载请注明原文地址:https://tech.qufami.com/read-19432.html