threads

Peter Hansen peter at engcorp.com
Tue Nov 11 11:24:45 EST 2003


Zunbeltz Izaola wrote:
> 
> I have create two threads (from threading module). I want to
> synchronize this two in the folowwing way
> 
> def Threa1func():
>         do stuff..
>         while something
>                 if test:
>                 CHANGE TO Thread2
>         do stuff...
> 
> def Thread2func():
>         do stuff ...
>         CHANGE TO Thread1
> 
> Thread1 = threading.Thread(target=Thread1func)
> Thread2 = threading.Thread(target=Thread2func)
> 
> them i've started this two threads
> 
> Thread1.start()
> Thread2.start()
> 
> I want to know if it is posible to do this CHANGE of threads.

Not exactly, or yes, depending on what you really want to do.

Can you describe the problem in different terms, without reference
to actual Python code or the threading module?  It's not at all clear
that you really want to use threads for your problem, and if you 
do, you are looking for a different concept than "CHANGE"... maybe
semaphores or something.

-Peter




More information about the Python-list mailing list