python创建线程示例

上传:sdl55474 浏览: 15 推荐: 0 文件:PDF 大小:26.81KB 上传时间:2020-12-31 19:51:11 版权申诉
复制代码 代码如下:import threadingfrom time import sleep def test_func(id): for i in range(0,5): sleep(1) print(‘thread %d is running %d’ % (id,i)) threads = []for i in range(0,3): t = threading.Thread(target=test_func, args=(i,)) threads.append(t) for t in threads: t.start() for t
上传资源
用户评论