[Tutor] Problem with threads
Kent Johnson
kent at kentsjohnson.com
Sat Feb 25 15:03:56 CET 2006
David Cohen wrote:
> Hi all,
>
> 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.
> Does anybody could help me?
More code would help. What you have shown looks fine. What does
func_thread() do? How do you know it isn't doing it? Here is a very
simple, working example based on your code:
import threading, time
def func_thread():
while True:
print 'threading'
time.sleep(1)
new_thread = threading.Thread(target = func_thread)
new_thread.start()
print "main thread going away now"
Kent
More information about the Tutor
mailing list