About threading.Thread

  • Thread starter 张佩佩
  • Start date
Å

张佩佩

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top