no parallel threading?
Tobias Unruh
Tobias_Unruh at FRM2.TU-Muenchen.DE
Wed Sep 5 13:37:13 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())
>
> >Why this result? From the first four lines I concluded that the threads
> >are executed one after the other (which is not intended). In this case,
> >however, the number of active threads should be 1 in any case. But these
> >values are ok. Is there something wrong with the output?
> >sys.stdout.flush() does not help.
>
> Your computer is too fast. Try cycling in test_funcs and use random
> sleep times (I even think, that you need delay loops: I am not sure
> what happens when you issue sleep. Probabbly the whole process sleeps.
> Then (probably) you will get intermingled strings.
Hm, I tried it with
def test_thread_func1():
k=0L
print "hello1"
for i in range(1000000):
k=k+1
print "hello1"
but nothing changed.
I installed now Python 2.2.a2. But again the same problem...
Do I have it to write in C++?
>
> BTW, this is what intrigued Linus most and was supported from the very
> first version of Linux ;-) (in processes, of course, not threads)
>
>
> Sincerely yours, Roman Suzi
> --
> _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/
> _/ Wednesday, September 05, 2001 _/ Powered by Linux RedHat 6.2 _/
> _/ "... Clinton sandwich: $5 of baloney and $20 in taxes" _/
>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
More information about the Python-list
mailing list