python 多线程threading
2015-06-06 00:00
555 查看
摘要: python 多线程threading
#!/usr/bin/env python
#-*- coding:utf-8 -*-
import time
import threading
def worker(id):
print 'id=',id
class Task(object):
def __call__(self,id):
print 'TASk:%s'% id
t = Task()
for i in range(5):
t1 = threading.Thread(target=t,args=(1,)) #参数值是元祖后面跟,逗号 target 可以是类名或者函数名 注意如果是类的话需要重写类的call 方法
t1.start()
#!/usr/bin/env python
#-*- coding:utf-8 -*-
import time
import threading
def worker(id):
print 'id=',id
class Task(object):
def __call__(self,id):
print 'TASk:%s'% id
t = Task()
for i in range(5):
t1 = threading.Thread(target=t,args=(1,)) #参数值是元祖后面跟,逗号 target 可以是类名或者函数名 注意如果是类的话需要重写类的call 方法
t1.start()
相关文章推荐
- python 多进程multiprocessing
- DataFrame与shp文件相互转换
- 使用HashRing实现python下的一致性hash
- python虚拟环境的使用
- Python函数式编程实践
- Python快速入门(5)
- Python模拟登陆
- python3支持excel读写
- [置顶] Python入门-函数的使用到程序的发布安装
- ubuntu下python opencv搭建
- LRU算法的Python实现
- python多重继承
- MySQLdb(Python)executemany和ON DUPLICATE KEY UPDATE的使用问题
- python 发邮件 utf-8
- python 时间戳 datetime string 转换
- Python问题记录:如何处理中文网页中的多余空格
- python django模型内部类meta详解
- python的一些零碎笔记
- python django直接执行sql语句
- 一行Python代码——单词逆转