Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #69711 > unrolled thread

About threading.Thread

Started by张佩佩 <zhangpeipei812@outlook.com>
First post2014-04-05 13:02 +0800
Last post2014-04-05 13:02 +0800
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python


Contents

  About threading.Thread 张佩佩 <zhangpeipei812@outlook.com> - 2014-04-05 13:02 +0800

#69711 — About threading.Thread

From张佩佩 <zhangpeipei812@outlook.com>
Date2014-04-05 13:02 +0800
SubjectAbout threading.Thread
Message-ID<mailman.8917.1396674262.18130.python-list@python.org>
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

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web