import time
import multiprocessing


def dance():
    for i in range(5):
        time.sleep(1)
        print("跳舞", i)


def sing():
    for i in range(5):
        time.sleep(1)
        print("唱歌", i)


if __name__ == '__main__':
    # 三个进程：一个主进程，二个子进程
    # 三个线程：一个进程一个线程

    # 创建子进程
    # Process：
    # target：指定执行的任务名（函数名）
    my_dance = multiprocessing.Process(target=dance)
    my_sing = multiprocessing.Process(target=sing)

    my_dance.start()
    my_sing.start()

1da3db9888ce0fe170db879bb6ee6e3303836b0a
<mask token>


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


<mask token>

<mask token>


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


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


<mask token>

<mask token>


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


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


if __name__ == '__main__':
    my_dance = multiprocessing.Process(target=dance)
    my_sing = multiprocessing.Process(target=sing)
    my_dance.start()
    my_sing.start()

import time
import multiprocessing


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


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


if __name__ == '__main__':
    my_dance = multiprocessing.Process(target=dance)
    my_sing = multiprocessing.Process(target=sing)
    my_dance.start()
    my_sing.start()

import time
import multiprocessing


def dance():
    for i in range(5):
        time.sleep(1)
        print("跳舞", i)


def sing():
    for i in range(5):
        time.sleep(1)
        print("唱歌", i)


if __name__ == '__main__':
    # 三个进程：一个主进程，二个子进程
    # 三个线程：一个进程一个线程

    # 创建子进程
    # Process：
    # target：指定执行的任务名（函数名）
    my_dance = multiprocessing.Process(target=dance)
    my_sing = multiprocessing.Process(target=sing)

    my_dance.start()
    my_sing.start()
