首页 > 解决方案 > 令人困惑的线程输出

问题描述

这段代码在不同的平台上给了我三种不同的输出

在在线 ide 上,输出是这个 https://www.online-python.com/AZ2Ggs35KU

在 IDLE 上的本地机器上,输出是这样的

嘿3

但根据我研究过的概念,输出应该是


2

import threading
import time 

def demo_func():
    print("hey")
    time.sleep(1)
    print("run")
    
t1 = threading.Thread(target = demo_func)
t1.start()
print(threading.activeCount())

标签: python-3.xpython-multithreading

解决方案


推荐阅读