🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
```python """ @Date 2021/4/5 """ import threading import time def demo1(): for i in range(5): print("demo1--%d" % i) time.sleep(1) def demo2(): for i in range(10): print("demo2--%d" % i) time.sleep(1) def main(): t1 = threading.Thread(target=demo1, name='demo1') t2 = threading.Thread(target=demo2, name='demo2') t1.start() t2.start() # 当前线程数量为3,main函数是一个线程,t1、t2也是线程 print("线程总数:{}".format(len(threading.enumerate()))) if __name__ == '__main__': main() ```