from threading import Thread
import time
import datetime
def func1():
print(f'{datetime.datetime.now()} func1 starting')
time.sleep(20)
print(f'{datetime.datetime.now()} func1 working')
time.sleep(20)
print(f'{datetime.datetime.now()} func1 ending')
def func2():
print(f'{datetime.datetime.now()} func2 starting')
time.sleep(20)
print(f'{datetime.datetime.now()} func2 working')
time.sleep(20)
print(f'{datetime.datetime.now()} func2 ending')
Thread(target=func1).start()
Thread(target=func2).start()
返回结果
2019-08-20 10:45:59.839427 func1 starting
2019-08-20 10:45:59.839821 func2 starting
2019-08-20 10:46:19.852530 func1 working
2019-08-20 10:46:19.859896 func2 working
2019-08-20 10:46:39.853510 func1 ending
2019-08-20 10:46:39.879981 func2 ending
网友评论