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()方法启动。

猜你喜欢

转载自blog.csdn.net/The_Time_Runner/article/details/105870263