Thread Question

Aahz aahz at pythoncraft.com
Wed Mar 1 17:11:24 CET 2006


In article <4404b15a_3 at newspeer2.tds.net>,
Kent Johnson  <kent at kentsjohnson.com> wrote:
>D wrote:
>>
>> My question is, how would I go
>> about creating the thread?  I have seen examples that used classes, and
>> other examples that just called one thread start command - when should
>> you use one over another?
>
>For simple use it doesn't matter. Use a class when you want to add more 
>state or behaviour - for example you might want a flag that tells the 
>thread to stop, or a Queue to communicate with the thread. A class might 
>be more convenient in these cases.
>
>IOW if you can write it as a single function it doesn't matter much 
>which form you use; for more complex usage you may want a class.

OTOH, always subclassing requires less thinking.
-- 
Aahz (aahz at pythoncraft.com)           <*>         http://www.pythoncraft.com/

"19. A language that doesn't affect the way you think about programming,
is not worth knowing."  --Alan Perlis



More information about the Python-list mailing list