python多进程之互斥锁
现在有三个人同时用一个打印机打印内容
三个进程同时模拟这三个人,输出平台模拟打印机
我们先写一个普通的多进程来看看
from multiprocessing import Process
import time
import os
import random
def task1():
print(f"{os.getpid()}开始打印了")
time.sleep(random.randint(1,3))
print(f"{os.getpid()}打印结束了")
def task2():
print(f"{os.getpid()}开始打印了")
time.sleep(random.randint(1,3))
print(f"{os.getpid()}打印结束了")
def