首页 > 编程语言 > 详细

多线程

时间:2019-06-20 21:24:42      阅读:104      评论:0      收藏:0      [点我收藏+]

 

from multiprocessing import Process
import time

def print_time(threadName, delay, iterations):
    start = int(time.time())
    for i in range(0,iterations):
        time.sleep(delay)
        seconds_elapsed = str(int(time.time()) - start)
        print (threadName if threadName else seconds_elapsed)


processes = []
processes.append(Process(target=print_time, args=(None, 1, 10)))
processes.append(Process(target=print_time, args=("Fizz", 3, 3)))
processes.append(Process(target=print_time, args=("Buzz", 5, 3)))

for p in processes:
    p.start()

for p in processes:
    p.join()
    
print("Program complete")

 

多线程

原文:https://www.cnblogs.com/sea-stream/p/11061269.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!