[Tutor] Problem with threads
Danny Yoo
dyoo at hkn.eecs.berkeley.edu
Sat Feb 25 20:54:49 CET 2006
On Sat, 25 Feb 2006, David Cohen wrote:
> I have a problem trying to use thread on python. I import the threading
> module and execute this:
>
> def func_thread():
> something...
>
> new_thread = threading.Thread(target = func_thread)
> new_thread.start()
>
> But the thread never really starts, just when I call the
> new_thread.join() method.
Hmmm... that's odd. Can you show us how you're determining this?
Here's an example interactive session:
###################################################
>>> import threading
>>> def sayHelloOverAndOver():
... while True:
... print "hello"
... time.sleep(10)
...
>>> import time
>>> t = threading.Thread(target=sayHelloOverAndOver)
>>> t.start()
hello
>>> hello
####################################################
Now every ten seconds, the word hello punctuates the prompt... and I can't
make it stop! *grin* Oh well.
Do you see the same kind of behavior on your end? Good luck!
More information about the Tutor
mailing list