# Create multi process demo code """ Format Process(target=Foo, args=("arg1", agg2, ....)) 1、target Is the task to be executed by this thread 2、args It's the parameters that are passed , It's a tuple , The content can be one or more , must ‘,’ ending 3、start function ,join Blocking the main process (join The main process will not continue until the process ends ), See ‘ Process start and join’ 4、Foo There is sleep, In case of serial, each output interval 2s, Parallel will be in sleep 2 Print together in seconds , Description is parallel """ from multiprocessing import Process import time def foo(n): time.sleep(2) print(n, time.ctime()) if __name__ == '__main__': p_list = [] for i in range(1, 4): p = Process(target=foo, args=("i",)) p_list.append(p) p.start() for p in p_list: p.join() print('end')