thread_free.py 367 字节
Newer Older
F
feilong 已提交
1
# -*- coding: UTF-8 -*-
F
feilong 已提交
2
# 作者:huanhuilong
F
feilong 已提交
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
# 标题:Python 多线程
# 描述:多线程打印 n

import threading
import time


def map_process(n):
    time.sleep(n)
    print(n)


def test():
    numbers = range(0, 3)
    for n in numbers:
        x = threading.Thread(target=map_process, args=(n,))
        x.start()


if __name__ == '__main__':
    test()