ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
```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() ```