Yes<br><br><div class="gmail_quote">On Wed, Feb 27, 2008 at 3:56 AM,  <<a href="mailto:castironpi@gmail.com">castironpi@gmail.com</a>> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
On Feb 26, 7:56 pm, "Gabriel Genellina" <<a href="mailto:gagsl-...@yahoo.com.ar">gagsl-...@yahoo.com.ar</a>><br>
wrote:<br>
> En Tue, 26 Feb 2008 01:46:48 -0200, Manikandan R <<a href="mailto:mani.ag...@gmail.com">mani.ag...@gmail.com</a>>  <br>
> escribió:<br>
<div class="Ih2E3d">><br>
> > Hai,<br>
><br>
> >           Is it possible to share a single variable between multiple<br>
> > threads. For eg:<br>
><br>
> > Class A:<br>
> >          thread_init()<br>
><br>
> >        def run():<br>
> >               fun1()<br>
><br>
> > def fun():<br>
> >  ........ assume some arithmatic operation is going on according to the<br>
</div><div class="Ih2E3d">> > input given and each fun will *give different output*<br>
> > .........<br>
><br>
> Store the result inside the thread object; that is, in run, self.result =  <br>
> fun1(...)<br>
><br>
</div><div class="Ih2E3d">> > Now 10 Thread will be running and each thread will have there individual<br>
> > output.<br>
><br>
> >        Here is the problem now i want the sum of output of all the  <br>
> > function.<br>
><br>
</div><div class="Ih2E3d">>  From your code I imagine you have a list of Thread instances;<br>
><br>
> global_result = sum([t.result for t in list_of_threads])<br>
><br>
> --<br>
> Gabriel Genellina<br>
<br>
</div>You can always hash the thread id: results[get_ident()]= result.<br>
<div><div></div><div class="Wj3C7c">--<br>
<a href="http://mail.python.org/mailman/listinfo/python-list" target="_blank">http://mail.python.org/mailman/listinfo/python-list</a><br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br><a href="http://search.goldwatches.com/?Search=Movado+Watches">http://search.goldwatches.com/?Search=Movado+Watches</a> <br><a href="http://www.jewelerslounge.com">http://www.jewelerslounge.com</a><br>
<a href="http://www.goldwatches.com">http://www.goldwatches.com</a>