python 多线程
来源:互联网 发布:无线传感器网络应用 编辑:程序博客网 时间:2024/06/06 08:37
#coding=utf-8import threadingfrom time import ctime,sleepdef Music(func): for i in range(2): print "I was listening to %s. %s \n" %(func,ctime()) sleep(1)def Run(): for i in range(2): print "I was Run! %s \n" %(ctime()) sleep(3)threads = []t1 = threading.Thread(target=Music,args=('God is a girl',))threads.append(t1)t2 = threading.Thread(target=Run)threads.append(t2)if __name__ == '__main__': for t in threads: t.setDaemon(True) t.start() t.join() print "all over %s" %ctime()
用python运行多线程,主要用到threading模块。t.join()保证子线程结束后运行主线程。
0 0
- Python多线程
- Python多线程
- Python多线程
- python多线程
- python 多线程
- python多线程
- python多线程
- python 多线程
- python多线程
- Python多线程
- Python 多线程
- python多线程
- python 多线程
- {python多线程}
- Python 多线程
- Python多线程
- python 多线程
- Python 多线程
- C#中调用Halcon导出类
- 模块加载失败 请确保该二进制文件在指定的路径中 找不到指定的模块
- Redux 简明教程
- bzoj3122: [Sdoi2013]随机数生成器
- 只更新数据库部分字段数据的方法
- python 多线程
- EBS FORMS 创建基本过程
- esrifeatureType
- IO端口与IO内存
- c# 笔记整理(2016年9月5日)
- iOS开发中无法安装cocoapods的问题
- Form的职责关系
- 如何预防 XSS 攻击?
- 设计模式题库