import multiprocessing
import time


# 跳舞任务,这个任务没有参数
def dance():
    for i in range(5):
        print("跳舞中...")
        time.sleep(0.2)


# 唱歌任务,这个任务没有参数
def sing():
    for i in range(5):
        print("唱歌中...")
        time.sleep(0.2)

if __name__ == '__main__':
    # 创建跳舞的子进程
    # group: 表示进程组，目前只能使用None
    # target: 表示执行的目标任务名(函数名、方法名)
    # name: 进程名称, 默认是Process-1, .....
    dance_process = multiprocessing.Process(target=dance, name="myprocess1")
    sing_process = multiprocessing.Process(target=sing)

    # 启动子进程执行对应的任务
    dance_process.start()
    sing_process.start()
da916a357f3ed903102f50518add75f604ae9399
<mask token>


def sing():
    for i in range(5):
        print('唱歌中...')
        time.sleep(0.2)


<mask token>

<mask token>


def dance():
    for i in range(5):
        print('跳舞中...')
        time.sleep(0.2)


def sing():
    for i in range(5):
        print('唱歌中...')
        time.sleep(0.2)


<mask token>

<mask token>


def dance():
    for i in range(5):
        print('跳舞中...')
        time.sleep(0.2)


def sing():
    for i in range(5):
        print('唱歌中...')
        time.sleep(0.2)


if __name__ == '__main__':
    dance_process = multiprocessing.Process(target=dance, name='myprocess1')
    sing_process = multiprocessing.Process(target=sing)
    dance_process.start()
    sing_process.start()

import multiprocessing
import time


def dance():
    for i in range(5):
        print('跳舞中...')
        time.sleep(0.2)


def sing():
    for i in range(5):
        print('唱歌中...')
        time.sleep(0.2)


if __name__ == '__main__':
    dance_process = multiprocessing.Process(target=dance, name='myprocess1')
    sing_process = multiprocessing.Process(target=sing)
    dance_process.start()
    sing_process.start()

import multiprocessing
import time


# 跳舞任务,这个任务没有参数
def dance():
    for i in range(5):
        print("跳舞中...")
        time.sleep(0.2)


# 唱歌任务,这个任务没有参数
def sing():
    for i in range(5):
        print("唱歌中...")
        time.sleep(0.2)

if __name__ == '__main__':
    # 创建跳舞的子进程
    # group: 表示进程组，目前只能使用None
    # target: 表示执行的目标任务名(函数名、方法名)
    # name: 进程名称, 默认是Process-1, .....
    dance_process = multiprocessing.Process(target=dance, name="myprocess1")
    sing_process = multiprocessing.Process(target=sing)

    # 启动子进程执行对应的任务
    dance_process.start()
    sing_process.start()