标签:mac print 多进程 col art python3 controls ssi display
from threading import Thread from multiprocessing import Process import os def work(name): print(‘{}的pid是‘.format(name), os.getpid()) if __name__ == ‘__main__‘: # part1:在主进程下开启多个线程,每个线程都跟主进程的pid一样 t1 = Thread(target=work,args=("thread1",)) t2 = Thread(target=work,args=("thread2",)) t1.start() t2.start() print(‘主线程/主进程pid‘, os.getpid()) # part2:开多个进程,每个进程都有不同的pid p1 = Process(target=work,args=("progress1",)) p2 = Process(target=work,args=("progress2",)) p1.start() p2.start() print(‘主线程/主进程pid‘, os.getpid())
macname@MacdeMacBook-Pro py % python3 cccccc.py thread1的pid是 78870 thread2的pid是 78870 主线程/主进程pid 78870 主线程/主进程pid 78870 progress1的pid是 78871 progress2的pid是 78872 macname@MacdeMacBook-Pro py %
标签:mac print 多进程 col art python3 controls ssi display
原文地址:https://www.cnblogs.com/sea-stream/p/14193444.html