[Tutor] Communicate between a thread and the main program
Dave Angel
davea at ieee.org
Mon Mar 8 13:51:33 CET 2010
Plato P.B. wrote:
> Hi all,
> I have created a script in which i need to implement the communication
> between the main program and a thread.
> The thread looks for any newly created files in a particular directory. It
> will be stored in a variable in the thread function. I want to get that name
> from the main program.
> How can i do it?
>
> Thanks in Advance. :D
>
Don't store it in "a variable in the thread function," but in an
instance attribute of the thread object.
Then the main program simply checks the object's attribute. Since it
launched the thread(s), it should know its (their) instances. This way,
the solution scales up as you add more threads, with different
functionality.
DaveA
More information about the Tutor
mailing list