彩照

一、学习【1】

  

 # -*- coding: utf-8 -*-
import time
import thread def timer(no, interval):
cnt = 0
while cnt < 10:
print 'Thread (%d), Time is %s \n' % (no, time.ctime())
time.sleep(interval)
cnt += 1
thread.exit_thread() def test():
thread.start_new_thread(timer, (1, 1))
thread.start_new_thread(timer, (2, 2)) if __name__ == '__main__':
test()
while 1:
pass
--------------------------------------

C:\Python27\python.exe E:/Project/actneed411/furion/static/js/shop/test_captcha.py
Thread (1), Time is Mon Aug 29 10:34:24 2016
Thread (2), Time is Mon Aug 29 10:34:24 2016


Thread (1), Time is Mon Aug 29 10:34:25 2016


Thread (2), Time is Mon Aug 29 10:34:26 2016
Thread (1), Time is Mon Aug 29 10:34:26 2016


Thread (1), Time is Mon Aug 29 10:34:27 2016


Thread (1), Time is Mon Aug 29 10:34:28 2016
Thread (2), Time is Mon Aug 29 10:34:28 2016


Thread (1), Time is Mon Aug 29 10:34:29 2016


Thread (2), Time is Mon Aug 29 10:34:30 2016
Thread (1), Time is Mon Aug 29 10:34:30 2016


Thread (1), Time is Mon Aug 29 10:34:31 2016


Thread (2), Time is Mon Aug 29 10:34:32 2016
Thread (1), Time is Mon Aug 29 10:34:32 2016


Thread (1), Time is Mon Aug 29 10:34:33 2016


Thread (2), Time is Mon Aug 29 10:34:34 2016


Thread (2), Time is Mon Aug 29 10:34:36 2016


Thread (2), Time is Mon Aug 29 10:34:38 2016


Thread (2), Time is Mon Aug 29 10:34:40 2016


Thread (2), Time is Mon Aug 29 10:34:42 2016

 

----------

  source:【1】Python多线程学习

python 线程学习的更多相关文章

  1. Python线程学习

    Python3 通过两个标准库 _thread 和 threading 提供对线程的支持. _thread 提供了低级别的.原始的线程以及一个简单的锁,它相比于 threading 模块的功能还是比较 ...

  2. python 线程 进程 协程 学习

    转载自大神博客:http://www.cnblogs.com/aylin/p/5601969.html 仅供学习使用···· python 线程与进程简介 进程与线程的历史 我们都知道计算机是由硬件和 ...

  3. Python学习——Python线程

    一.线程创建 #方法一:将要执行的方法作为参数传给Thread的构造方法 import threading import time def show(arg): time.sleep(2) print ...

  4. python——线程与多线程进阶

    之前我们已经学会如何在代码块中创建新的线程去执行我们要同步执行的多个任务,但是线程的世界远不止如此.接下来,我们要介绍的是整个threading模块.threading基于Java的线程模型设计.锁( ...

  5. Python 多线程学习(转)

    转自:http://www.cnblogs.com/slider/archive/2012/06/20/2556256.html 引言 对于 Python 来说,并不缺少并发选项,其标准库中包括了对线 ...

  6. Python 线程(threading) 进程(multiprocessing)

    *:first-child { margin-top: 0 !important; } body>*:last-child { margin-bottom: 0 !important; } /* ...

  7. Day1 Python基础学习

    一.编程语言分类 1.简介 机器语言:站在计算机的角度,说计算机能听懂的语言,那就是直接用二进制编程,直接操作硬件 汇编语言:站在计算机的角度,简写的英文标识符取代二进制去编写程序,本质仍然是直接操作 ...

  8. Day1 Python基础学习——概述、基本数据类型、流程控制

    一.Python基础学习 一.编程语言分类 1.简介 机器语言:站在计算机的角度,说计算机能听懂的语言,那就是直接用二进制编程,直接操作硬件 汇编语言:站在计算机的角度,简写的英文标识符取代二进制去编 ...

  9. Python 系统学习梳理_【All】

    Python学习 1. Python学习---Python安装与基础1205 2. Python学习---PyCharm的使用学习 3. Python学习---Python数据类型1206 4. Py ...

随机推荐

  1. jQuery ajax 返回的数据类型

    请求数据的接口信息如下 当我们打印出返回的数据与数据节点时,我们发现数据节点显示为undefind 查看一下我们的代码 $.ajax({ type: "Post", url: &q ...

  2. c# word 转pdf 导出失败,因为此功能尚未安装

    savePDF应该是office2007以上的版本才支持的,而且必须是完整版的office. 如果2007提示这个错误,还需要安装一个插件 http://download.microsoft.com/ ...

  3. wkhtmltopdf 中文参数详解

    linux:wkhtmltopdf [OPTIONS]… [More input files] windows:wkhtmltopdf.exe [OPTIONS]… [More input files ...

  4. mysql apache php install

    设置LINUX自动匹配环境变量 1.$su #su进入root #vi /etc/profile 在文件末尾加上下列语句: PATH=$PATH:/sbin #在PATH变量后追加/sbin目录 ex ...

  5. SVN 多项目管理(强烈建议每个项目建一个库)

    Subversion的目录结构是很自由的,所有的规划都必须是你自己规定,考虑一个 subversion仓库的目录树,你可以把任何一个目录认定为一个项目,你可以只checkout这个目录下的所有文件进行 ...

  6. java操作MySQL数据库(插入、删除、修改、查询、获取所有行数)

    插播一段广告哈:我之前共享了两个自己写的小应用,见这篇博客百度地图开发的两个应用源码共享(Android版),没 想到有人找我来做毕设了,年前交付,时间不是很紧,大概了解了下就接下了,主要用到的就是和 ...

  7. MongoDb 聚合报错

    聚合框架它是数据聚合的一个新框架,其概念类似于数据处理的管道. 每个文档通过一个由多个节点组成的管道,每个节点有自己特殊的功能(分组.过滤等),文档经过管道处理后,最后输出相应的结果. 管道基本的功能 ...

  8. 【001:转载 ubuntu下: 建立本地SVN服务器】

    1.安装 svn 工具 $sudo apt-get install subversion 2.  创建工程文件夹,用于存放工程 $mkdir ~/localsvn $mkdir ~/localsvn/ ...

  9. 助手系列之连接mysql数据库

    import MySQLdbdef main(): try: conn=MySQLdb.connect(host='127.0.0.1',user='root',passwd='pass',db='a ...

  10. javaWeb 使用 filter 处理全站乱码问题

    1. web.xml文件中的配置 <filter> <filter-name>CharacterEncodingFilter</filter-name> <f ...