guopengfa
发布于 2020-08-11 / 767 阅读 / 0 评论 / 0 点赞

pandas多线程串行与并行,运行与阻塞

import pandas as pd
import numpy as np
import time
import threading

def run1():
    time.sleep(5)
    print("run1,Even start!")

def run2():
    time.sleep(5)
    print("run2,Even start!")
def run3():
    print("run3,Even start!")

pro1 = threading.Thread(target=run1)
pro1.start()
pro2 = threading.Thread(target=run2)
pro2.start()
pro2.join()
pro3 = threading.Thread(target=run3)
pro3.start()

如上所示,任务一,任务二执行完成之后才会执行任务三,这是因为join()阻塞了线程


评论