Python多线程模块threading、_thread

  • Python标准库

    _thread and threading are both Python standard module, _thread module provides low-level primitives for working with multiple threads(also called light-weight processes or tasks).

    Multiple threads of control sharing their global data space.For synchronization, simple locks (also called mutexes or binary semaphores) are provided. The threading module provides an easier to use and higher-level threading API built on top of _thread.

  • threading 常用命令

    1. threading.active_count() 当前活跃的线程数目
    2. threading.current_thread() 当前活跃的线程
    3. threading.Thread() 新建线程对象,独立于控制线程之外。需要用run()方法启动。
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章