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()方法啓動。
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章