Help doing simple threading

David Lees deblNonOspammy at theworld.com
Wed Mar 14 23:14:51 EST 2001


Thanks, these comment were quite helpful.  The most serious error was
'a)'.  when I just put the main to sleep after starting up the threads
it worked fine.  The problem was that I was printing out the array
values, before all the threads finished executing.

David

Andreas Jung wrote:
> 
<snip>
> 
> Your code has several problems:
> 
> a) You don't synchronize your main thread with the threads you start.
>     That means your main thread continues running BEFORE the
>     started threads make any work.
> 
> b) Modifying shared resources within threads is dangerous. Think
>    about using locks to get rid of this problem.
> 
> c) Try the threading module. It gives you a better control and programmer
>     interface to work with thread in Python.
> 
> ----
> Andreas Jung (andreas at digicool.com)
> Digital Creations - www.digicool.com, www.zope.org



More information about the Python-list mailing list