Fwd: Problem with threads in python????????
Gabriel Genellina
gagsl-py2 at yahoo.com.ar
Tue Feb 26 20:56:27 EST 2008
En Tue, 26 Feb 2008 01:46:48 -0200, Manikandan R <mani.agape at gmail.com>
escribió:
> Hai,
>
> Is it possible to share a single variable between multiple
> threads. For eg:
>
> Class A:
> thread_init()
>
> def run():
> fun1()
>
> def fun():
> ........ assume some arithmatic operation is going on according to the
> input given and each fun will *give different output*
> .........
Store the result inside the thread object; that is, in run, self.result =
fun1(...)
> Now 10 Thread will be running and each thread will have there individual
> output.
>
> Here is the problem now i want the sum of output of all the
> function.
From your code I imagine you have a list of Thread instances;
global_result = sum([t.result for t in list_of_threads])
--
Gabriel Genellina
More information about the Python-list
mailing list