About threading.Thread

张佩佩 zhangpeipei812 at outlook.com
Sat Apr 5 01:02:59 EDT 2014


Hello guys:
 I have an question on threading.Thread
My code is here:
File1:
a.py
import threading
import time
def hello():
	while True:
		print('hello')
		threads = threading.enumerate()
		for thread in threads:
			print(thread.getName())
		time.sleep(3)
def fun():
	a = threading.Thread(target=hello(), name='hello')
	print("a file: I won't display!")
	a.start()
File2:
b.py
import time
from a import fun
fun()
print("b file: I won't display!")
When I run: python b.py (python version: 2.7.6, 3.3.5, 3.4.0)
It seems that threading.Thread() in file1 not create a new thread but use MainThread.
Anyone can explain this ?
Thank you in advance.
Best regards.
peipei


More information about the Python-list mailing list

AltStyle によって変換されたページ (->オリジナル) /