官方参考文档:https://docs.python.org/3.7/library/_thread.html

_thread库方法

(1) _thread.error

(2)_thread.LockTyoe

(3)_thread.start_new_thread

(4)_thread.interrupt_main

  Raise a KeyboardInterrupt exception in the main thread. A subthread can use this function to interrupt the main thread.

(5)_thread.exit

(6)_thread.allocate_lock

import _thread

a_lock = _thread.allocate_lock()

with a_lock:
print("a_lock is locked while this executes")

(7)_thread.get_ident

(8)_thread.stack_size

(9)_thread.TIMEOUT_MAX

(10)lock.acquire(waitflag=1,timeout=-1)

  Without any optional argument, this method acquires the lock unconditionally, if necessary waiting until it is released by another thread (only one thread at a time can acquire a lock — that’s their reason for existence).

  If the integer waitflag argument is present, the action depends on its value: if it is zero, the lock is only acquired if it can be acquired immediately without waiting, while if it is nonzero, the lock is acquired unconditionally as above.

  If the floating-point timeout argument is present and positive, it specifies the maximum wait time in seconds before returning. A negative timeout argument specifies an unbounded wait. You cannot specify a timeout if waitflag is zero.

  The return value is True if the lock is acquired successfully, False if not.

(11)lock.release()

(12)lock.locked()

  

python库之_thread的更多相关文章

  1. python库之threading

    This module constructs higher-level threading interfaces on top of the lower level python库之_threadmo ...

  2. 11个并不广为人知,但值得了解的Python库

    这是一篇译文,文中提及了一些不常见但是有用的Python库 原文地址:http://blog.yhathq.com/posts/11-python-libraries-you-might-not-kn ...

  3. python自动化测试(4)-使用第三方python库技术实现

    python自动化测试(4)-使用第三方python库技术实现 1   概述 关于测试的方法论,都是建立在之前的文章里面提到的观点: 功能测试不建议做自动化 接口测试性价比最高 接口测试可以做自动化 ...

  4. OSX下 pip更新及安装python库

    直接执行安装命令 $ pip install builtwith 提示pip当前版本为7.1.2,要使用"pip install --upgrade pip"升级到8.1.2 $  ...

  5. protocol buffer c++ python库安装

    c++库安装较简单,不要用源码,还得下载依赖,就被墙了 https://github.com/google/protobuf/releases  下载一个最新的release安装 #protoc -- ...

  6. Windows版的各种Python库安装包下载地址与安装过程

    在用Python开发时(Windows环境),会碰到需要安装某个版本的第三方库,为了以后查找.安装方便,总结如下: windows版的各种Python库安装包下载地址:http://www.lfd.u ...

  7. python 线程之_thread

    python 线程之_thread _thread module: 基本用法: def child(tid): print("hello from child",tid) _thr ...

  8. Python 库大全

    作者:Lingfeng Ai链接:http://www.zhihu.com/question/24590883/answer/92420471来源:知乎著作权归作者所有.商业转载请联系作者获得授权,非 ...

  9. python库tkinter、pygame中几点需要注意的问题

    恍然之间已经16年快四月份了,已经好久都没有写过东西了.. 最近在用python做一些小的游戏,在网上找了一些Python库,Python中游戏编程最常用的还是pygame了,其次是Tkinter p ...

随机推荐

  1. java 工厂模式的作用,为什么要用工厂模式以及示例演示

    1 工厂模式的作用,为什么要用工厂模式? 工厂模式是为了解耦:把对象的创建和使用的过程分开.就是Class A 想调用Class B,那么只是调用B的方法,而至于B的实例化,就交给工厂类. 工厂模式可 ...

  2. HDU4627

    /*找规律,n是奇数那么就是n/2和n/2+1 如果n是偶数,那就是两种情况n/2-1,和n/2-2两种,比较一下大小就可以 思路来自:http://www.cnblogs.com/freezhan/ ...

  3. Linux:查看磁盘空间占用情况

    Linux:查看磁盘空间占用情况 工作中有时被分配的测试机空间不大,经常遇到磁盘空间占满的情况.排查过程如下: 一.首先使用df -h 命令查看磁盘剩余空间,通过以下图看出/目录下的磁盘空间已经被占满 ...

  4. C\C++与Java中的static关键字

    C\C++里面的static: 面向过程的static: 在c和c++面向过程的设计里,在全局变量前加上static关键字则可将该变量定义为一个静态全局变量,比如: static int a; 那么c ...

  5. Spring_Bean 的作用域

    beans-scope.xml <?xml version="1.0" encoding="UTF-8"?><beans xmlns=&quo ...

  6. HDU 1238 Substing

    思路: 1.找出n个字符串中最短的字符串Str[N] 2.从长到短找Str[N]的子子串 subStr[N],以及subStr[N]的反转字符串strrev(subStr[N]):(从长到短是做剪枝处 ...

  7. 如何实现一个简单的RPC

    在如何给老婆解释什么是RPC中,我们讨论了RPC的实现思路. 那么这一次,就让我们通过代码来实现一个简单的RPC吧! RPC的实现原理 正如上一讲所说,RPC主要是为了解决的两个问题: 解决分布式系统 ...

  8. AMD C1E SUPPORT

    •C1E是一种电源管理状态,它可以让处理器节能不限于处理器内核.在CIE状态,可以通过降低内存时钟速度.关闭HT技术,来降低处理器能耗.这种新功能对于12核的处理器极其重要,因为这种处理器在设计上既增 ...

  9. “玲珑杯”ACM比赛 Round #13 B -- 我也不是B(二分排序)

    题意:开始有一个空序列s,一个变量c=0,接着从左往右依次将数组a中的数字放入s的尾部,每放一个数字就检测一次混乱度K,当混乱度k大于M时就清空序列并让c=c+1 K = Bi * Vi(1<= ...

  10. Spring-boot CLI下载

    Spring-boot CLI下载地址: https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#getting-s ...