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


Groups > comp.lang.python > #69711

About threading.Thread

From 张佩佩 <zhangpeipei812@outlook.com>
Subject About threading.Thread
Date 2014-04-05 13:02 +0800
Newsgroups comp.lang.python
Message-ID <mailman.8917.1396674262.18130.python-list@python.org> (permalink)

Show all headers | View raw


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

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

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

csiph-web