Newbie Threads question

Phil Mayes nospam at bitbucket.com
Sat May 1 21:39:35 EDT 1999


Michael "Fred" Fredericks wrote in message
<7gfdrm$69t$1 at nnrp1.dejanews.com>...
>What I'd like to do is learn how to use threads by "parallelizing" a simple
>set of now currently serialized tasks.
> [sample code snipped]
>#my new main loop
>list1 = thread.start_new_thread(func1,(x))
>list2 = thread.start_new_thread(func2,(y))
>reallist = func3(list1,list2)
>
>I have read the documentation a couple of times, but what I don't know:
>[...]
>B) Do I need to do anything fancy to make the func3 call wait until the
calls
>to func1 and func2 have both returned? For example, should I have the func1
>and func2 calls aquire a lock at the start of the function and release it
at
>the end, and then make the main loop try to acquire both locks before
>proceeding to the reallist = func3() call?  If I did this, could the main
>loop acquire the locks before the new threads do, causing deadlock?


There is a nifty class called WorkQ that will wait on N threads in
    python\python-1.5.2\demo\threads\find.py
courtesy of Guido.  You may need to download the source-code to get this --
not sure.
--
Phil Mayes    pmayes AT olivebr DOT com
Olive Branch Software - home of Arranger http://www.olivebr.com/








More information about the Python-list mailing list