# coding:utf-8
import time
from multiprocessing import Process
def func1():
print("func1 start...")
time.sleep(1)
print("func1 end...")
def func2():
print("func2 start...")
time.sleep(1)
print("func2 end...")
if __name__ == '__main__':
print("主程序开始了.")
p1 = Process(target=func1,)
p2 = Process(target=func2,)
p1.start()
p2.start()
print("子程序1名字:", p1.name)
print("子程序2名字:", p2.name)
print("主程序结束了.")
执行结果:
# 主程序开始了.
# 子程序1名字: Process-1
# 子程序2名字: Process-2
# 主程序结束了.
# func1 start...
# func2 start...
# func1 end...
# func2 end...
python3 获取子进程的name
猜你喜欢
转载自www.cnblogs.com/lilyxiaoyy/p/10964630.html
今日推荐
周排行