彩照

一、学习【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. DBXJSON和ADO的效率真的好低....

    项目需要写了一个JSON和DataSet互转的单元.....支持了Delphi自带的几种DataSet, 结果发现DBXJSON和ADO的效率真的是好低啊........-_-.... 开发环境是XE ...

  2. robots

    User-agent: Baiduspider Disallow: /w? Allow: / User-agent: Googlebot Allow: / User-agent: Googlebot- ...

  3. Android动画设计源码地址

    Android动画设计源码地址 http://blog.csdn.net/shanghaibao123/article/details/45223825

  4. Java学习-047-数值格式化及小数位数四舍五入

    此小工具类主要用于数值四舍五入.数值格式化输出,很简单,若想深入研究,敬请自行查阅 BigDecimal 或 DecimalFormat 的 API,BigDecimal.setScale(位数,四舍 ...

  5. LeetCode Smallest Rectangle Enclosing Black Pixels

    原题链接在这里:https://leetcode.com/problems/smallest-rectangle-enclosing-black-pixels/ 题目: An image is rep ...

  6. 传入一个label或者button,传入5s,6和6+的文字尺寸 快速定义文字大小

    func isIphone6() -> Bool { { return true } else { return false } } func isIphone6Plus() -> Boo ...

  7. Python介绍、安装、使用

    Python介绍.安装.使用 搬运工:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.Python语言介绍 说到Python语言,就不得不说一下它的创始人Guido van Rossu ...

  8. mysql部署到云主机的笔记

    写了个程序,需要把数据库部署到云主机上 MySQL基于安全考虑root账户一般只能本地访问,但是在开发过程中可能需要打开root的远程访问权限 为了安全,新添加一个用户来进行远程登录 登录MYSQL: ...

  9. URL编码与解码

    在项目中碰到了ajax传来的参数,后台接收值乱码(如下图)的问题 在此记录一下 前台: 后台: 解决问题 为什么需要编码 怎样编码 实际出现的问题解决方法 1.为什么需要编码? URL 只能使用 AS ...

  10. XAF去掉View页面的编辑器

    如图,去掉该编辑器功能. 1.detailView   protected override void OnActivated()        {            base.OnActivat ...