Fwd: Problem with threads in python????????
James Matthews
nytrokiss at gmail.com
Wed Feb 27 15:04:23 EST 2008
Yes
On Wed, Feb 27, 2008 at 3:56 AM, <castironpi at gmail.com> wrote:
> On Feb 26, 7:56 pm, "Gabriel Genellina" <gagsl-... at yahoo.com.ar>
> wrote:
> > En Tue, 26 Feb 2008 01:46:48 -0200, Manikandan R <mani.ag... 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
>
> You can always hash the thread id: results[get_ident()]= result.
> --
> http://mail.python.org/mailman/listinfo/python-list
>
--
http://search.goldwatches.com/?Search=Movado+Watches
http://www.jewelerslounge.com
http://www.goldwatches.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20080227/004d4dbc/attachment-0001.html>
More information about the Python-list
mailing list