What is wrong with my Python threading?

Chuckk Hubbard badmuthahubbard at gmail.com
Wed May 21 03:33:34 EDT 2008


On Tue, May 20, 2008 at 4:28 PM, castironpi <castironpi at gmail.com> wrote:
> On May 20, 8:19 am, "Chuckk Hubbard" <badmuthahubb... at gmail.com>
> wrote:
>> #!/usr/bin/python
>>
>> #why doesn't this run both threads simultaneously?
>> #Thanks for any help.
>> #Chuckk
>>
>> import threading
>> import time
>>
>> def printesc(thrd):
>>     for i in range(10):
>>         time.sleep(1)
>>         print thrd, i
>>
>> def master():
>>     thd1 = threading.Thread(target=printesc, args=(1,))
>>     thd2 = threading.Thread(target=printesc, args=(2,))
>>     thd1.run()
>>     thd2.run()
>>
>> master()
>
> You meant 'thd1.start( )' and 'thd2.start( )'.

So I did.  I was mixing what I read of thread and threading.  I'll
never wander beyond my Python module reference html folder again.
Thanks for your help.

-Chuckk

-- 
http://www.badmuthahubbard.com



More information about the Python-list mailing list