python库之threading

Thismoduleconstructshigher-levelthreadinginterfacesontopofthelowerlevelpython库之_threadmo

大家好,又见面了,我是全栈君,今天给大家准备了Idea注册码。

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

  官方参考文档:https://docs.python.org/2/library/threading.html

threading库对象和方法

(1)threading.active_count()

(2)theading.Condition()

  A factory function that returns a new condition variable object,See Condition Objects.

(3)threading.current_thread()

(4)threading.enumerate()

  Return a list of all Thread objects currently alive. The list includes daemonic threads, dummy thread objects created by current_thread(), and the main thread. It excludes terminated threads and threads that have not yet been started.

(5)threading.event()

  A factory function that returns a new event object. An event manages a flag that can be set to true with the set() method and reset to false with the clear() method. The wait() method blocks until the flag is true.See Event Objects.

(6)class threading.local 

   A class that represents thread-local data. Thread-local data are data whose values are thread specific. To manage thread-local data, just create an instance of local (or a subclass) and store attributes on it:

  mydata = threading.local()   mydata.x = 1 

  The instance’s values will be different for separate threads.

  For more details and extensive examples, see the documentation string of the _threading_local module.

(7)theading.Lock()

  A factory function that returns a new primitive lock object. Once a thread has acquired it, subsequent attempts to acquire it block, until it is released; any thread may release it.See Lock Objects.

(8)threading.RLock()

  A factory function that returns a new reentrant lock object. A reentrant lock must be released by the thread that acquired it. Once a thread has acquired a reentrant lock, the same thread may acquire it again without blocking; the thread must release it once for each time it has acquired it.See RLock Objects.

(9)threading.Semaphore([value])

  A factory function that returns a new semaphore object. A semaphore manages a counter representing the number of release() calls minus the number of acquire() calls, plus an initial value. The acquire() method blocks if necessary until it can return without making the counter negative. If not given, value defaults to 1.See Semaphore Objects.

(10)threading.BoundedSemaphore([value])

  A factory function that returns a new bounded semaphore object. A bounded semaphore checks to make sure its current value doesn’t exceed its initial value. If it does, ValueError is raised. In most situations semaphores are used to guard resources with limited capacity. If the semaphore is released too many times it’s a sign of a bug. If not given, value defaults to 1.

(11)class threading.Thread

  A class that represents a thread of control. This class can be safely subclassed in a limited fashion.See Thread Objects.

(12)class threading.Timer

  A thread that executes a function after a specified interval has passed.See Timer Objects.

(13)threading.settrace(func)

(14)threading.setprofile(func)

(15)threading.stack_size([size])

 

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/120069.html原文链接:https://javaforall.cn

【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛

【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...

(0)


相关推荐

  • Android TabLayout设置setupWithViewPager标题不显示

    Android TabLayout设置setupWithViewPager标题不显示

  • 如何用python画爱心表白_python 简短 表白

    如何用python画爱心表白_python 简短 表白利用python画爱心表白

  • Java单例模式(Singleton)以及实现「建议收藏」

    Java单例模式(Singleton)以及实现「建议收藏」一.什么是单例模式因程序需要,有时我们只需要某个类同时保留一个对象,不希望有更多对象,此时,我们则应考虑单例模式的设计。二.单例模式的特点单例模式只能有一个实例。单例类必须创建自己的唯一实例。单例类必须向其他对象提供这一实例。三.单例模式VS静态类在知道了什么是单例模式后,我想你一定会想到静态类,“既然只使用一个对象,为何不干脆使用静态类?”,这里我会将单例模式和静态类进行一个比较。单例可以继承和被继承,方法可以被override,而静态方法不可以。静态方

  • VUE打包图片加载失败问题

    VUE打包图片加载失败问题昨天的搬运工,今天的小雷锋。 问题描述,使用VUE-CLI打包后,出现图片无法显示情况。这里可能存在两种情况:静态资源CSS中使用图片作为背景图片使用时。 在JS中生成图片标签后,再设置图片路径时。 当你吃着火锅唱着歌,一路npm-run-dev都相安无事的时候,打包完事后,发现突然图片显示异常了!如果你观察后,你会发现组件中使用的img标签都没任何问题,我们css中的背景图片…

  • Bitmap.MakeTransparent 方法

    Bitmap.MakeTransparent 方法使默认的透明颜色对此Bitmap透明。重载列表使默认的透明颜色对此Bitmap对象透明。[Visual Basic]OverloadsPublicSubMakeTransparent()[C#]publicvoidMakeTransparent();[C++]public:voidMakeTransparent();[JScript]publicfunctionM

  • H2数据库入门_H2数据库越来越大

    H2数据库入门_H2数据库越来越大一、H2简介  1、H2是一个用Java开发的嵌入式数据库,它本身只是一个类库,可以直接嵌入到应用项目中。  H2最大的用途在于可以同应用程序打包在一起发布,这样可以非常方便地存储少量结构化数据。  它的另一个用途是用于单元测试。启动速度快,而且可以关闭持久化功能,每一个用例执行完随即还原到初始状态。  H2的第三个用处是作为缓存,作为NoSQL的一个补充。当某些场景下数据模型必须为关系型…

    2022年10月12日

发表回复

您的电子邮箱地址不会被公开。

关注全栈程序员社区公众号