# 多进程

### 基于多进程的并发

```python
import time
import multiprocessing

def task(i):
    print('task {} start'.format(i))
    time.sleep(i)
    print('task {} end'.format(i))

if __name__ == '__main__':
    start = time.time()

    # 基于多进程的并发
    p_list = []
    for i in range(1, 6):
        p = multiprocessing.Process(target=task, args=(i,))
        p.start()
        p_list.append(p)

    for p in p_list:
        p.join()

    print('耗时: {}s'.format(time.time() - start))
```
