1. import threading
    2. import time
    3. g_list = list()
    4. def add_list():
    5. for item in range(5):
    6. g_list.append(item)
    7. print(item)
    8. time.sleep(0.2)
    9. pass
    10. pass
    11. def read_list():
    12. print(g_list)
    13. pass
    14. if __name__ == '__main__':
    15. add_thread = threading.Thread(target=add_list)
    16. add_thread.start()
    17. # 当前进程等待add_thread进程执行完之后,才能够往下执行
    18. add_thread.join()
    19. read_thread = threading.Thread(target=read_list)
    20. read_thread.start()