no parallel threading?

Rainer Deyke root at rainerdeyke.com
Wed Sep 5 15:15:57 EDT 2001


> On Wed, 5 Sep 2001, Tobias Unruh wrote:
>
> >Hi,
> >
> >I tried to execute two threads in parallel (linux 2.4.9, python 2.0):
> >
> >import time
> >import threading
> >
> >def test_thread_func1():
> >    print "Hallo1"
> >    time.sleep(3.0)
> >    print "Hallo1"
> >
> >def test_thread_func2():
> >    print "Hallo2"
> >    time.sleep(3.0)
> >    print "Hallo2"
> >
> >printlock = threading.Lock()
> >
> >test_thread1 = threading.Thread(None,test_thread_func1())
> >test_thread2 = threading.Thread(None,test_thread_func2())
                                                         ^^

You are calling 'test_thread_func1', and passing the result to
'threading.Thread'.  In other words, your function has already terminated
before the thread object is created.  Try leaving off the '()' after
'test_thread_func1' and 'test_thread_func2'.


--
Rainer Deyke (root at rainerdeyke.com)
Shareware computer games           -           http://rainerdeyke.com
"In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor





More information about the Python-list mailing list