Python的多线程
来源:互联网 发布:免费建站 知乎 编辑:程序博客网 时间:2024/06/11 00:20
#coding=utf-8
#包含threading 模块
from time import ctime,sleep
def music(func):
for i in range(2):
print "I was listening to %s. %s" %(func,ctime())
sleep(1)
def move(func):
for i in range(2):
print "I was at the %s! %s" %(func,ctime())
sleep(5)
threads = []
t1 = threading.Thread(target=music,args=(u'爱情买卖',))
threads.append(t1)
t2 = threading.Thread(target=move,args=(u'阿凡达',))
threads.append(t2)
if __name__ == '__main__':
for t in threads:
#setDaemon(True)将线程声明为守护线程,必须在start() 方法调用之前设置,如果不设置为守护线程程序会被无限挂起。
t.start()
#join()的作用是,在子线程完成运行之前,这个子线程的父线程将一直被阻塞。
t.join()
print "all over %s" %ctime()
阅读全文
0 0
- Python里的多线程
- python的多线程实例
- python的多线程分析
- python的多线程
- python的多线程示例
- Python多线程的学习
- python的多线程
- python的多线程基础设施
- 多线程的python实现
- python的多线程
- Python的多线程
- python 多线程的使用
- [Language]Python的多线程
- Python的多线程
- python多线程的使用
- python的多线程
- python多线程,获取多线程的返回值
- 简单的学习Python多线程
- html页面嵌入时间和日期
- sql server与mysql差异收集
- 如何在CentOS 5/6上安装EPEL 源
- 在CentOS上安装phpMyAdmin的教程
- SO_REUSEADDR和SO_REUSEPORT异同
- Python的多线程
- Prim算法求最小生成树
- 解决zabbix在configure时候遇到的问题(Ubuntu)
- 使用autoconf生成Makefile.in文件
- Linux创建线程的属性设置
- 1970年计算的时间转日期
- 简单电路实验
- mysql复合主键如何设定自增长属性
- java用递归方法返回文件下的所有子目录