CPython 2 allowed threads to switch after executing a certain number of byte codes; CPython 3.2 is modified to allow threads to switch after a while. Your test()executes a lot of byte codes, but consumes little time. In my field under Python 3, the displayed result becomes unpredictable if I add, for example, this is near the beginning:
import sys
sys.setswitchinterval(sys.getswitchinterval() / 10.0)
, 10 ( ).
, _thread Python 3: . threading.Thread, :
for i in range(10):
t = threading.Thread(target=test)
t.start()