python多进程处理

import threading


def task1():
    print("扔第二个苹果")



def task2():
    print("扔第三个苹果")


def main():
    # threading.Thread 创建一个线程
    thread1 = threading.Thread(target=task1())
    # 让线程执行
    thread1.start()
    thread2 = threading.Thread(target=task2())
    thread2.start()
    print("扔第一个苹果")

import time
def task1():
    time.sleep(5)



def main():
    start_time = time.time()
    thread1 = threading.Thread(target=task1())
    thread2 = threading.Thread(target=task1())
    thread1.start()
    thread2.start()
    # 让其他线程等待自己执行完成
    thread1.join()
    thread2.join()
    end_time = time.time()
    print(end_time - start_time)
上一篇:【王喆-推荐系统】评估篇-(task1)离线评估方法


下一篇:天池零基础入门NLP竞赛实战:Task1&Task2 数据读取与数据分析