Python 多线程 类和方法
2016-05-26 16:14
363 查看
import threading import time import random def threadFun(): for i in range(10): print("ThreadFun - %d" %i) time.sleep(random.randrange(0,2)) class ThreadClass(threading.Thread): def __init__(self): threading.Thread.__init__(self) def run(self): for i in range(10): print("ThreadClass - %d" %i) time.sleep(random.randrange(0,2)) if __name__ == "__main__": tFunc = threading.Thread(target = threadFun) tCls = ThreadClass() tFunc.start() tCls.start() tFunc.join() tCls.join()
相关文章推荐
- Python错误与异常
- 生成python程序的exe文件
- python datetime模块基本用法
- python面向对象详解(转)
- python-目录
- python os.path模块
- python带setup.py的包的安装
- python的切片与迭代
- 好消息! 不用再羡慕Python有jupyter 我R也有Notebook了【附演示视频】
- python如何支持中文注释
- Python通过LDAP验证、查找用户(class,logging)
- python04-函数的定义、调用与递归
- 树状数组与其应用(Python实现)(1)
- python实战项目
- python中VC编译器版本的对应关系
- Python实现可自定义更新策略的LRU Cache
- Python 基础学习笔记6- 多变量赋值
- python函数
- python数据分析
- Python学习笔记之字典