博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
python 多线程_thread
阅读量:4312 次
发布时间:2019-06-06

本文共 1084 字,大约阅读时间需要 3 分钟。

 

import _threadimport timedef 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)try:    _thread.start_new_thread(print_time, (None, 1, 10))    _thread.start_new_thread(print_time, ("Fizz", 3, 3))    _thread.start_new_thread(print_time, ("Buzz", 5, 3))except:    print ("Error: unable to start thread")while 1:    pass

demo2

import _threadimport timedef 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)try:    _thread.start_new_thread(print_time, (None, 1, 10))    _thread.start_new_thread(print_time, ("Fizz", 3, 3))    _thread.start_new_thread(print_time, ("Buzz", 5, 3))except:    print ("Error: unable to start thread")print("complete!")

 

转载于:https://www.cnblogs.com/sea-stream/p/11062751.html

你可能感兴趣的文章
Excel 如何制作时间轴
查看>>
matplotlib绘图跳过时间段的处理方案
查看>>
vnpy学习_04回测评价指标的缺陷
查看>>
iOS开发中遇到的问题整理 (一)
查看>>
Linux(SUSE 12)安装jboss4并实现远程访问
查看>>
Neutron在给虚拟机分配网络时,底层是如何实现的?
查看>>
netfilter/iptables全攻略
查看>>
Overlay之VXLAN架构
查看>>
Eclipse : An error occurred while filtering resources(Maven错误提示)
查看>>
在eclipse上用tomcat部署项目404解决方案
查看>>
web.xml 配置中classpath: 与classpath*:的区别
查看>>
suse如何修改ssh端口为2222?
查看>>
详细理解“>/dev/null 2>&1”
查看>>
suse如何创建定时任务?
查看>>
suse搭建ftp服务器方法
查看>>
centos虚拟机设置共享文件夹并通过我的电脑访问[增加smbd端口修改]
查看>>
文件拷贝(IFileOperation::CopyItem)
查看>>
MapReduce的 Speculative Execution机制
查看>>
大数据学习之路------借助HDP SANDBOX开始学习
查看>>
Hadoop基础学习:基于Hortonworks HDP
查看>>