python 线程学习
彩照
一、学习【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 线程学习的更多相关文章
- Python线程学习
Python3 通过两个标准库 _thread 和 threading 提供对线程的支持. _thread 提供了低级别的.原始的线程以及一个简单的锁,它相比于 threading 模块的功能还是比较 ...
- python 线程 进程 协程 学习
转载自大神博客:http://www.cnblogs.com/aylin/p/5601969.html 仅供学习使用···· python 线程与进程简介 进程与线程的历史 我们都知道计算机是由硬件和 ...
- Python学习——Python线程
一.线程创建 #方法一:将要执行的方法作为参数传给Thread的构造方法 import threading import time def show(arg): time.sleep(2) print ...
- python——线程与多线程进阶
之前我们已经学会如何在代码块中创建新的线程去执行我们要同步执行的多个任务,但是线程的世界远不止如此.接下来,我们要介绍的是整个threading模块.threading基于Java的线程模型设计.锁( ...
- Python 多线程学习(转)
转自:http://www.cnblogs.com/slider/archive/2012/06/20/2556256.html 引言 对于 Python 来说,并不缺少并发选项,其标准库中包括了对线 ...
- Python 线程(threading) 进程(multiprocessing)
*:first-child { margin-top: 0 !important; } body>*:last-child { margin-bottom: 0 !important; } /* ...
- Day1 Python基础学习
一.编程语言分类 1.简介 机器语言:站在计算机的角度,说计算机能听懂的语言,那就是直接用二进制编程,直接操作硬件 汇编语言:站在计算机的角度,简写的英文标识符取代二进制去编写程序,本质仍然是直接操作 ...
- Day1 Python基础学习——概述、基本数据类型、流程控制
一.Python基础学习 一.编程语言分类 1.简介 机器语言:站在计算机的角度,说计算机能听懂的语言,那就是直接用二进制编程,直接操作硬件 汇编语言:站在计算机的角度,简写的英文标识符取代二进制去编 ...
- Python 系统学习梳理_【All】
Python学习 1. Python学习---Python安装与基础1205 2. Python学习---PyCharm的使用学习 3. Python学习---Python数据类型1206 4. Py ...
随机推荐
- P1079 Vigenère 密码
#include <bits/stdc++.h> using namespace std; const int maxn = 1005; int main() { freopen(&quo ...
- Java初始化生命周期
package com.init; abstract class Glyph { void draw() { System.out.println("Glyph.draw()"); ...
- do put in ruby
apikey: XO.apikeys.cms, data: { favoriteItems: [{ UserId: SaveToFavoriteVar.content.FavoriteItem.Use ...
- JS中的_proto_
var grandfather = function(){ this.name = "LiuYashion" ; } var father = function(){}; fath ...
- iis 部署 webapi2.0 访问报错解决
本机安装的VS2013 开发环境,在IIS部署WebApi2.0时,应用程序池并没有.NET4.5的选项. 网上搜索一番得知: 1..NET 4.5本质上还是4.0,属于递增式的更新,所以对IIS 来 ...
- H5页面实现一个Audio标签加载多个音频文件,并进行播放和展示音频长度
最近微信项目中有需求,要将微信端发送过来的amr格式的语音文件,在项目中的页面上进行展示和播放,实现方式如下: 1.首先java后台收到微信端的消息推送的时候,使用 ffmpeg将amr格式的音频文件 ...
- Display Voxel Gird and PCA
https://github.com/yhexie/NDTEX 最近科研没有思路,写点代码加强基础知识的学习吧. 下面写了一个点云体素分割,PCA计算体素内点云的特征值和特征向量.
- .NET中string[]数组和List<string>泛型的相互转换以及Array类的Sort()方法(转)
从string[]转List<string>: " }; List<string> list = new List<string>(str); 从List ...
- Python Decorator 和函数式编程
看到一篇翻译不错的文章,原文链接: Python Decorator 和函数式编程
- 我的AngularJS 学习之旅(二)
记得某位大神说过,"时间就像海绵里的水,挤挤总是有的.".大多时候,与其说我是很忙而没时间去做自己想做的事, 倒不如说是懒得去做罢了. 废话不多说,接前一篇继续吧 3.3 指令(D ...