nested threading

Aahz aahz at pythoncraft.com
Fri Apr 9 19:38:17 EDT 2010


In article <4566e767-768f-4399-8a6b-5530ec90b03c at a37g2000prd.googlegroups.com>,
Omer Ihsan  <omrihsan at gmail.com> wrote:
>
>is there anything as "nested threading"....that is, call a thread from
>within a thread.
>in this case how will thread locking take place.
>
>for example initially there were two functions that were called using
>threading.Thread. these wont get unlocked unless both of them are done
>with whatever they need to do. if say function 2 calls another thread.
>then what??

You need to do the locking explicitly.  There's really no such thing as
a nested thread in Python -- it's all a "flat namespace".  However,
trying to nest threads conceptually is likely to get you into deadlock
issues.  You are more likely to make things work if you just start all
threads in parallel.
-- 
Aahz (aahz at pythoncraft.com)           <*>         http://www.pythoncraft.com/

"...string iteration isn't about treating strings as sequences of strings, 
it's about treating strings as sequences of characters.  The fact that
characters are also strings is the reason we have problems, but characters 
are strings for other good reasons."  --Aahz



More information about the Python-list mailing list