https://blog.csdn.net/weixin_44917390/article/details/119610760
创建多进程方法:
import multiprocessing import time def sing(): for i in range(3): print("i am sing ooo~") time.sleep(0.5) def dance(): for i in range(3): print("i am dance lll~") time.sleep(0.5) if __name__ == '__main__': # 2.使用进程类创建进程对象 # target :指定进程执行的函数名,不加括号 sing_process = multiprocessing.Process(target=sing) dance_process = multiprocessing.Process(target=dance) # 3. 使用进程对象启动进程执行指定任务 sing_process.start() dance_process.start()
多线程创建
import threading import time def sing(): for i in range(3): print("i am sing ooo~") time.sleep(0.5) def dance(): for i in range(3): print("i am dance lll~") time.sleep(0.5) if __name__ == '__main__': sing_thread = threading.Thread(target=sing) dance_thread = threading.Thread(target=dance) sing_thread.start()标签:__,target,python,dance,time,进程,sing,多线程 From: https://www.cnblogs.com/xiao-longxia/p/17509488.html